Web lists-archives.com

SIGCHLD handler is not restored properly


Recently we noticed that GSubprocess breaks the SIGCHLD handler in QProcess [1]. Glib hijacks this handler for the entire process, without "chain handling" the old (overwritten) handler. It seems that the faulty code is in gmain.c::ref_unix_signal_handler_unlocked:

sigaction (signum, &action, NULL);

According to the sigaction documentation, if the 3rd arg is non-NULL, the previous action is saved and can be restored later with another call to sigaction. But what Glib does is, it restores the signal handler to a SIG_DFL in gmain.c::unref_unix_signal_handler_unlocked:

action.sa_handler = SIG_DFL;

I am not aware of any way on how to workaround this from code using Glib, so it seems that this would need to be addressed in Glib itself. What do you think?

[1] https://bugreports.qt.io/browse/QTBUG-56338

gtk-devel-list mailing list