FAQ
Is there a way to listen to all child processes exit ? Actually i can
wait for a process exit using Process wait but I has to be done /
process when i could get all exit using wait(2) on the system and
check against the returned pid.

- benoît

--

Search Discussions

  • Minux at Nov 9, 2012 at 6:56 am

    On Fri, Nov 9, 2012 at 2:53 PM, Benoit Chesneau wrote:

    Is there a way to listen to all child processes exit ? Actually i can
    wait for a process exit using Process wait but I has to be done /
    process when i could get all exit using wait(2) on the system and
    check against the returned pid.
    This operation is not portable across supported OSes, so you need to use
    package syscall directly.

    --
  • Kevin Gillette at Nov 10, 2012 at 11:11 am
    A minimum-feature compatible library could be created, though if something
    equivalent to wait isn't present on all platforms, it'd be pretty
    inefficient to emulate.
    On Thursday, November 8, 2012 11:56:22 PM UTC-7, minux wrote:


    On Fri, Nov 9, 2012 at 2:53 PM, Benoit Chesneau <bche...@gmail.com<javascript:>
    wrote:
    Is there a way to listen to all child processes exit ? Actually i can
    wait for a process exit using Process wait but I has to be done /
    process when i could get all exit using wait(2) on the system and
    check against the returned pid.
    This operation is not portable across supported OSes, so you need to use
    package syscall directly.
    --
  • Dustin Sallings at Nov 10, 2012 at 7:38 pm
    Kevin Gillette
    <extemporalgenome@gmail.com> writes:

    A minimum-feature compatible library could be created, though if
    something equivalent to wait isn't present on all platforms, it'd be
    pretty inefficient to emulate.
    The OP kept responding off-list. This functionality in this case was
    needed to port a non-go solution to go. The go solution is far easier
    and more reliable (i.e. just have a goroutine monitor each process
    specifically and react to exits).

    --
    dustin

    --
  • Benoit Chesneau at Nov 10, 2012 at 7:45 pm
    ahhh sorry my bad.... I sisn't realized that I wasn't replying to all.
    So yes I will go for a pure go solution. I will see how it goes :-)

    - benoît
    On Sat, Nov 10, 2012 at 8:38 PM, Dustin Sallings wrote:
    Kevin Gillette
    <extemporalgenome@gmail.com> writes:

    A minimum-feature compatible library could be created, though if
    something equivalent to wait isn't present on all platforms, it'd be
    pretty inefficient to emulate.
    The OP kept responding off-list. This functionality in this case was
    needed to port a non-go solution to go. The go solution is far easier
    and more reliable (i.e. just have a goroutine monitor each process
    specifically and react to exits).

    --
    dustin

    --
    --
  • Dustin Sallings at Nov 10, 2012 at 8:05 pm
    Benoit Chesneau <bchesneau@gmail.com>
    writes:
    ahhh sorry my bad.... I sisn't realized that I wasn't replying to all.
    So yes I will go for a pure go solution. I will see how it goes :-)
    Sure, let us know if something gets hard. That's often an indicator
    of a better path one missed.

    --
    dustin

    --
  • Dustin Sallings at Nov 9, 2012 at 7:09 am
    Benoit Chesneau <bchesneau@gmail.com>
    writes:
    Is there a way to listen to all child processes exit ? Actually i can
    wait for a process exit using Process wait but I has to be done /
    process when i could get all exit using wait(2) on the system and
    check against the returned pid.
    Depending on what you're trying to do, there could be an easy way with
    goroutines and channels or WaitGroups delivering the responses.

    --
    dustin

    --
  • Dustin Sallings at Nov 9, 2012 at 8:18 am
    I seemed to have received this off-list. Bringing it back in case
    anyone else has something to offer.
    On Nov 8, 2012, at 23:18, Benoit Chesneau wrote:

    I want to supervise a bunch of OS processes calling different on a
    machine and collect their exit so I can eventually restart one or
    collect the result of this process.

    I can probably do it using sync.WaitGroups or a channel indeed but was
    wondering how efficient it can be.
    The only reason you'd worry about efficiency in supervising processes
    is if you're polling, I'd think. Most of the time, the processes are
    running and your app is idle.

    I don't know why you'd not do the most obvious thing -- just spawn a
    goroutine for every process you want to supervise and have it manage
    that child. You can have a shared channel to send the results from all
    of them, or do so in isolation or whatever.

    One goroutine per process is pretty much required to achieve your goal
    and it's likely the easiest way to do it and at least as efficient as
    whatever you'd be doing to track the state of each process so you'd know
    what died or emitted output anyway.

    --
    dustin

    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedNov 9, '12 at 6:53a
activeNov 10, '12 at 8:05p
posts8
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase