|| at Nov 27, 2012 at 5:21 pm
On Tuesday, November 27, 2012 11:13:08 AM UTC-5, Petar Maymounkov wrote:
Using Go's standard libraries (os/exec, syscall, os, etc.), is it possible
to exec a child process in such a
manner that the child dies if the parent does. I'm emphasizing on "using
Go's standard libraries" so that the
solution be portable at least on Linux, OSX, BSD.
A fairly common solution, in C at least, is to use a `lifeline' socket
which is installed in the child's fd table by the parent before exec. The
parent holds the other end of the socket (or pipe) and, should it die, the
kernel will close that end, resulting in an EOF that's visible to the child.
On the minus side, this requires the child to explicitly process the EOF on
the socket. On the plus side, that allows the child to clean up before