[Nix-dev] [PATCH] Make `build-remote.pl' work with GNU lshd

Ludovic Courtès ludovic.courtes at inria.fr
Fri Dec 9 14:01:11 CET 2011


Hi,

Eelco Dolstra <e.dolstra at tudelft.nl> skribis:

> On 09/12/11 11:21, Ludovic Courtès wrote:
>
>> (The behavior of lshd seems OK to me since the subshell gets a copy of
>> the parent shell’s stdin, so closing one shouldn’t close the other.)
>
> I don't think so.  It's not about closing but getting an EOF.  I would expect
> lshd to close the write side of the shell's stdin, so that any child process
> that attempts to read from it gets EOF.

Yes, but the subshell gets a /duplicate/ of the shell’s stdin.

>> -if (system("exec ssh $hostName @sshOpts '(read; kill -INT -\$\$) <&0 & nix-store -r $drvPath $buildFlags > /dev/null' 2>&4") != 0) {
>> +if (system("exec ssh $hostName @sshOpts 'trap \"kill -INT -\$\$\" SIGPIPE ; nix-store -r $drvPath $buildFlags > /dev/null' 2>&4") != 0) {
>
> Does this actually work?

It works in the common case (no SIGPIPE).

> A process only gets a SIGPIPE if it does a write(), right?

Right, good point.

Hmm I’m not even sure why these things need to be done.  Suppose your
run “ssh host foo”; when the SSH daemon loses the connection, doesn’t it
kill ‘foo’ automatically?

Thanks,
Ludo’.


More information about the nix-dev mailing list