Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
Process.daemon
(?untyped nochdir, ?untyped noclose) -> ::Integer
Process.daemon(nochdir = nil, noclose = nil) → 0
process.c
View on GitHub ↗
static VALUE
proc_daemon(int argc, VALUE *argv, VALUE _)
{
int n, nochdir = FALSE, noclose = FALSE;
switch (rb_check_arity(argc, 0, 2)) {
case 2: noclose = TO_BOOL(argv[1], "noclose");
case 1: nochdir = TO_BOOL(argv[0], "nochdir");
}
prefork();
n = rb_daemon(nochdir, noclose);
if (n < 0) rb_sys_fail("daemon");
return INT2FIX(n);
}
Detaches the current process from its controlling terminal and runs it in the background as system daemon; returns zero.
By default:
-
Changes the current working directory to the root directory.
-
Redirects $stdin, $stdout, and $stderr to the null device.
If optional argument nochdir is true, does not change the current working directory.
If optional argument noclose is true, does not redirect $stdin, $stdout, or $stderr.