Glib.IO.add_watch HUP signal issues on Mac OS X

Piotr Esden-Tempski <[email protected]> Wed, 13 Nov 2013 15:40:24 -0800
Newsgroups gmane.comp.lang.ocaml.lib.gtk
Message-ID <[email protected]>
Hi everyone,

I am trying to debug an issue on Mac OS X. I tried to describe as much as I could with a bunch of examples here: https://github.com/paparazzi/paparazzi/issues/290

TLDR: When watching a pipe connected to a child process, Linux machines send a IO_HUP signal when the child exits. On Darwin this is not happening. The alternative used to be to wait for the OUT signal instead that. Since 10.8 the OUT signal is arriving immediately when a process starts, which breaks the kludgy fix.

I bet that waiting for the OUT signal was a kludge in the first place. It was surprising that it was working in the first place, but it did the job.

Now my questions.

1) Did anyone of you guys encounter this problem too? (Maybe I am just missing something very obvious.)

2) If there is no way of fixing this in lablgtk or glib and it actually is a bug in Darwin itself, what alternatives would you guys propose? During my research I found the child_watch_add function in glib. From my understanding this would be a perfect candidate to replace the way and purpose we are using add_watch for currently. But as far as I can tell it is not available through lablgtk2 bindings. So let me know if there is another way of asynchronously monitoring child processes.

All help is very appreciated.

Cheers,
Esden