From: Mark Wooding Date: Sun, 3 Jun 2018 22:37:39 +0000 (+0100) Subject: with-authinfo-kludge: Fix race between `setpgrp' and `kill'. X-Git-Tag: 0.1.2~2 X-Git-Url: https://git.distorted.org.uk/~mdw/with-authinfo-kludge/commitdiff_plain/e6a99993368725e4d48983433d4980f0899f9acc with-authinfo-kludge: Fix race between `setpgrp' and `kill'. Make up a pipe so we don't try to `kill' (actually, arrange to continue) our new process group before it's actually become a process group. --- diff --git a/with-authinfo-kludge b/with-authinfo-kludge index d1bb048..28a2c0d 100755 --- a/with-authinfo-kludge +++ b/with-authinfo-kludge @@ -831,13 +831,19 @@ sub run_client (@) { my (@args) = @_; inform "starting client"; + pipe my $r, my $w or sysfail "failed to create pipe: $!"; defined (my $kid = myfork) or sysfail "failed to fork: $!"; if (!$kid) { hack_noip_env \%CLIENT_NOIP, "$SESSDIR/noip-client"; setpgid $$, $$ or sysfail "failed to set kid process group: $!"; + close $w; close $r; my $prog = $args[0]; exec @args or sysfail "failed to exec `$prog': $!"; } + close $w; + defined sysread $r, my $buf, 1 + or sysfail "failed to read pipe: $!"; + close $r; $CLIENTKID = $kid; write_to_file "$SESSDIR/client.pid", "$kid\n"; maybe_foreground_client;