+ elsif ($cmd =~ /\s-DSERVER=wait:(\d+)\s/)
+ {
+ my $listen_port = $1;
+ my $waitmode_sock = new FileHandle;
+ if ($debug) { printf ">> wait-mode daemon: $cmd\n"; }
+ run_system("sudo mkdir spool/log 2>/dev/null");
+ run_system("sudo chown $parm_eximuser:$parm_eximgroup spool/log");
+
+ my ($s_ip,$s_port) = ('127.0.0.1', $listen_port);
+ my $sin = sockaddr_in($s_port, inet_aton($s_ip))
+ or die "** Failed packing $s_ip:$s_port\n";
+ socket($waitmode_sock, PF_INET, SOCK_STREAM, getprotobyname('tcp'))
+ or die "** Unable to open socket $s_ip:$s_port: $!\n";
+ setsockopt($waitmode_sock, SOL_SOCKET, SO_REUSEADDR, 1)
+ or die "** Unable to setsockopt(SO_REUSEADDR): $!\n";
+ bind($waitmode_sock, $sin)
+ or die "** Unable to bind socket ($s_port): $!\n";
+ listen($waitmode_sock, 5);
+ my $pid = fork();
+ if (not defined $pid) { die "** fork failed: $!\n" }
+ if (not $pid) {
+ close(STDIN);
+ open(STDIN, "<&", $waitmode_sock) or die "** dup sock to stdin failed: $!\n";
+ close($waitmode_sock);
+ print "[$$]>> ${cmd}-server\n" if ($debug);
+ exec "exec ${cmd}-server";
+ exit(1);
+ }
+ while (<SCRIPT>) { $lineno++; last if /^\*{4}\s*$/; } # Ignore any input
+ select(undef, undef, undef, 0.3); # Let the daemon get going
+ return (3, { exim_pid => $pid }); # Don't wait
+ }