On Mon, Feb 12, 2018 at 5:18 PM, Amandeep Gautam
<amandeepgaut...@gmail.com> wrote:
> I am writing a process monitoring solution in go for AIX. I would like to
> signal the child process when the parent dies so that it does not become
> orphaned. In linux, one can set PdeathSig
> (https://golang.org/pkg/syscall/#SysProcAttr) and Go will take care of the
> rest. However this attribute is absent for other operating system, like AIX.
> Can someone provide pointers on how this can be achieved?

To the best of my knowledge only GNU/Linux and FreeBSD support
prctl(PR_SET_PDEATHSIG) which is the kernel API for this.  As far as I
know this is not available on AIX.  There are various ways that the
child process could test whether it has been orphaned, but I don't
know of any way to certainly kill the child.  In Go, one approach you
would use would be an os.Pipe in the parent.  Have the child closing
the writing end, and start a goroutine that reads from the reading
end.  If that read ever completes, the parent has died and the kernel
has closed the descriptor.


You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to