FAQ
I am wondering:

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.

Thanks
Petar

--

Search Discussions

  • Russ Cox at Nov 27, 2012 at 4:43 pm
    On Linux you can use the "pdeathsig" functionality, which is exposed
    by package syscall.
    I am unaware of any similar functionality for OS X or BSD.

    Russ

    --
  • Danny Gratzer at Nov 27, 2012 at 4:49 pm
    Are you limiting yourself purely to unix? On windows there isn't really a
    notion of parent-child process relationships.

    On Tue, Nov 27, 2012 at 10:43 AM, Russ Cox wrote:

    On Linux you can use the "pdeathsig" functionality, which is exposed
    by package syscall.
    I am unaware of any similar functionality for OS X or BSD.

    Russ

    --


    --
    Danny Gratzer

    --
  • Job van der Zwan at Nov 27, 2012 at 4:52 pm

    On Tuesday, 27 November 2012 17:49:35 UTC+1, Danny Gratzer wrote:
    Are you limiting yourself purely to unix? On windows there isn't really a
    notion of parent-child process relationships.


    On Tue, Nov 27, 2012 at 10:43 AM, Russ Cox <r...@golang.org <javascript:>>wrote:
    On Linux you can use the "pdeathsig" functionality, which is exposed
    by package syscall.
    I am unaware of any similar functionality for OS X or BSD.

    Russ

    --


    --
    Danny Gratzer
    It's not shown by the default task manager, but there is - try Process
    Explorer instead and click on "process" a few times until it sorts by
    parent-child tree.
    http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx

    --
  • Petar Maymounkov at Nov 27, 2012 at 5:15 pm
    Yeah. It's seems you are right. E.g. here's what I noticed

    ssh linuxhost "tail -f /tmp/file"
    ^C

    kills the remote tail process after Ctrl-C on the localhost.
    On the other hand:

    ssh osxhost "tail -f /tmp/file"
    ^C

    Does not.

    Somehow this feels upsetting :) ssh "tail -f" leaves
    zombies and there is no way around it :)

    Petar
    On 27 November 2012 11:43, Russ Cox wrote:
    On Linux you can use the "pdeathsig" functionality, which is exposed
    by package syscall.
    I am unaware of any similar functionality for OS X or BSD.

    Russ
    --
  • Agl 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
    dying.


    Cheers

    AGL

    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedNov 27, '12 at 4:13p
activeNov 27, '12 at 5:21p
posts6
users5
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase