g_spawn callback when child exits



I am using g_spawn_async_with_pipes() to control a subprocess which
takes commands on stdin.  The parent needs to know when the child is
running and when it has exited however so that it does not get a
SIGPIPE trying to send a command to the process after it has exited.

I guess I am going to have to install a signal handler to reap the
child when it has exited and toggle a flag so that the parent knows
not to send any more commands.  I imagine knowing when the child is
running and when it is finished is a common problem though.  It would
be nice to be able to install a callback with the g_spawn_*()
functions to be called when the child exits.

Could g_spawn_*() not install a SIGCHLD handler that calls a
registered callback when a child process exits?  Having g_spawn_*()
handle this would be much cleaner than the developer having to do it
themselves, no?

b.

-- 
Brian J. Murrell

Attachment: pgp7xFoFrZaBx.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]