aboutsummaryrefslogtreecommitdiffstats
path: root/process.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-07-10 19:18:48 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-07-10 19:21:47 +0900
commitc8d0470bb0888bcb6719ba536e5f3f6a8b6551bb (patch)
tree98536f216cd90b7987629c95b8d2f03f2ec9a3e6 /process.c
parent092c9b266ab3175c40a78e8af99bb82a0f3d2f4b (diff)
downloadruby-c8d0470bb0888bcb6719ba536e5f3f6a8b6551bb.tar.gz
Use `File::NULL` instead of hard coded null device names
Diffstat (limited to 'process.c')
-rw-r--r--process.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/process.c b/process.c
index b4435446f0..fe9c0a31d7 100644
--- a/process.c
+++ b/process.c
@@ -4804,11 +4804,11 @@ rb_f_system(int argc, VALUE *argv, VALUE _)
*
* A filename can be specified as a hash value.
*
- * pid = spawn(command, :in=>"/dev/null") # read mode
- * pid = spawn(command, :out=>"/dev/null") # write mode
+ * pid = spawn(command, :in=>File::NULL) # read mode
+ * pid = spawn(command, :out=>File::NULL) # write mode
* pid = spawn(command, :err=>"log") # write mode
- * pid = spawn(command, [:out, :err]=>"/dev/null") # write mode
- * pid = spawn(command, 3=>"/dev/null") # read mode
+ * pid = spawn(command, [:out, :err]=>File::NULL) # write mode
+ * pid = spawn(command, 3=>File::NULL) # read mode
*
* For stdout and stderr (and combination of them),
* it is opened in write mode.
@@ -6834,7 +6834,7 @@ static int rb_daemon(int nochdir, int noclose);
* nochdir is true (i.e. non false), it changes the current
* working directory to the root ("/"). Unless the argument
* noclose is true, daemon() will redirect standard input,
- * standard output and standard error to /dev/null.
+ * standard output and standard error to null device.
* Return zero on success, or raise one of Errno::*.
*/
@@ -6854,6 +6854,8 @@ proc_daemon(int argc, VALUE *argv, VALUE _)
return INT2FIX(n);
}
+extern const char ruby_null_device[];
+
static int
rb_daemon(int nochdir, int noclose)
{
@@ -6877,7 +6879,7 @@ rb_daemon(int nochdir, int noclose)
if (!nochdir)
err = chdir("/");
- if (!noclose && (n = rb_cloexec_open("/dev/null", O_RDWR, 0)) != -1) {
+ if (!noclose && (n = rb_cloexec_open(ruby_null_device, O_RDWR, 0)) != -1) {
rb_update_max_fd(n);
(void)dup2(n, 0);
(void)dup2(n, 1);