Workaround needed for silent kill() failure in OS X
Imported from http://bugzilla.roxen.com/bugzilla/show_bug.cgi?id=4793
Reported by Jonas Wallden jonasw@roxen.com
Test 349 from modules/testsuite seems to hang intermittently on OS X. A distilled test case:
class Fnord {
int gnapp(int t)
{
int e;
werror("#%d: STARTING\n", t);
for (e = 0; e < 7; e++) {
for (int d = 0; d < 150; d++) {
object o = Process.create_process( ({ "/bin/sleep", "99999" }) );
int err = kill(o->pid(), 9);
o->wait();
}
}
werror("#%d: DONE\n", t);
return -1;
}
array start()
{
array a = ({ });
for (int e = 0; e < 10; e++)
a += ({ thread_create(gnapp, e) });
return a;
}
};
void main()
{
werror("starting...\n");
array res = Fnord()->start()->wait() - ({ -1 });
werror("res: %O\n", res);
}
With tracing enabled in signal_handler.c we've determined that the kill() call in f_kill() returns without error but doesn't terminate the targeted process. The problem has yet to be reduced to a standalone C program, but one hypothesis is that the forked /bin/sleep has not yet started completely before the SIGKILL signal is delivered and that the OS X kernel therefore disregards the signal.