GNOME Bugzilla – Bug 592962
Fix gjs_crash_after_timeout() problems
Last modified: 2009-08-25 17:21:43 UTC
I noticed that 'make distcheck' would run succesfully, then a few minutes later I would get a whole bunch of horrible spew on the terminal where I ran the distcheck.
Created attachment 141603 [details] [review] Fix gjs_crash_after_timeout() problems Fix two major issues with gjs_crash_after_timeout(): * It didn't notice the parent exiting normally so the forked off child would keep running until the timeout. This is fixed by using a pipe between the parent and child and watching for the pipe to get immediate notification of parent exit. * The forked off child process would return to the caller of gjs_crash_after_timeout() after the timeout completed and it killed the parent this would typically fail horribly. Call exit() instead.
owen asked me to look at this since no gjs people were around... This seems very heavyweight for just a "make sure the regresssion tests eventually get killed" hack... It seems like it should work though. You probably want _exit(), not exit(), in both places. The use of spaces before parentheses in your code does not match the rest of the file. You misspelled "FD_CLOEXEC" as "F_CLOEXEC" twice in non-code.
Thanks for the review. It did occur to me after writing this "I probably could just have used sleep(1); kill(pid, 0) in a loop". But then I had already written it, and writing it twice seemed heavyweight for a "make sure regression tests eventually get killed hack" too. Spaces, FD_CLOEXEC, _exit() fixed, pushed.