Feature #2619 » 0001-Add-method-Process.fork_supported-for-checking-wheth.patch
process.c | ||
---|---|---|
#if defined NO_WAITPID
|
||
result = wait(data);
|
||
#elif defined HAVE_WAITPID
|
||
#ifdef __APPLE__
|
||
if (arg->flags & WNOHANG) {
|
||
result = waitpid(arg->pid, arg->st, arg->flags);
|
||
} else {
|
||
result = 0;
|
||
while (result == 0) {
|
||
result = waitpid(arg->pid, arg->st, arg->flags | WNOHANG);
|
||
if (result == 0) {
|
||
usleep(10000);
|
||
}
|
||
}
|
||
}
|
||
#else
|
||
result = waitpid(arg->pid, arg->st, arg->flags);
|
||
#endif
|
||
#else /* HAVE_WAIT4 */
|
||
result = wait4(arg->pid, arg->st, arg->flags, NULL);
|
||
#endif
|
||
... | ... | |
/*
|
||
* call-seq:
|
||
* Process.fork_supported? # => boolean
|
||
*
|
||
* Returns whether forking subprocesses is supported on the current platform.
|
||
* If not, then it indicates that <code>Kernel.fork</code> and
|
||
* <code>Process.fork</code> will raise NotImplementedError.
|
||
*/
|
||
static VALUE
|
||
rb_f_fork_supported_p(VALUE obj)
|
||
{
|
||
#if defined(HAVE_FORK) && !defined(CANNOT_FORK_WITH_PTHREAD)
|
||
return Qtrue;
|
||
#else
|
||
return Qfalse;
|
||
#endif
|
||
}
|
||
/*
|
||
* call-seq:
|
||
* Process.exit!(fixnum=-1)
|
||
*
|
||
* Exits the process immediately. No exit handlers are
|
||
... | ... | |
rb_define_singleton_method(rb_mProcess, "exec", rb_f_exec, -1);
|
||
rb_define_singleton_method(rb_mProcess, "fork", rb_f_fork, 0);
|
||
rb_define_singleton_method(rb_mProcess, "fork_supported?", rb_f_fork_supported_p, 0);
|
||
rb_define_singleton_method(rb_mProcess, "spawn", rb_f_spawn, -1);
|
||
rb_define_singleton_method(rb_mProcess, "exit!", rb_f_exit_bang, -1);
|
||
rb_define_singleton_method(rb_mProcess, "exit", rb_f_exit, -1);
|