From 8af6f91a981feb36c4db63b076df4a4bf241e8aa Mon Sep 17 00:00:00 2001 From: mishina Date: Sat, 28 Dec 2024 09:19:59 +0900 Subject: [PATCH] style: Suppress Style/FileNull cop --- lib/god/cli/run.rb | 4 ++-- lib/god/process.rb | 6 +++--- test/test_process.rb | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/god/cli/run.rb b/lib/god/cli/run.rb index 4aa364c1..fdfa4926 100644 --- a/lib/god/cli/run.rb +++ b/lib/god/cli/run.rb @@ -111,13 +111,13 @@ def run_daemonized def setup_logging log_file = God.log_file log_file = File.expand_path(@options[:log]) if @options[:log] - log_file = '/dev/null' if !log_file && @options[:daemonize] + log_file = File::NULL if !log_file && @options[:daemonize] return unless log_file puts "Sending output to log file: #{log_file}" unless @options[:daemonize] # reset file descriptors - $stdin.reopen '/dev/null' + $stdin.reopen File::NULL $stdout.reopen(log_file, 'a') $stderr.reopen $stdout $stdout.sync = true diff --git a/lib/god/process.rb b/lib/god/process.rb index b7a6ad6d..9f7fc0b8 100644 --- a/lib/god/process.rb +++ b/lib/god/process.rb @@ -9,7 +9,7 @@ class Process :stop_timeout, :stop_signal, :umask def initialize - self.log = '/dev/null' + self.log = File::NULL @pid_file = nil @tracking_pid = true @@ -139,7 +139,7 @@ def valid? applog(self, :error, "CHROOT directory '#{chroot}' does not exist") end - unless File.exist?(File.join(chroot, '/dev/null')) + unless File.exist?(File.join(chroot, File::NULL)) valid = false applog(self, :error, "CHROOT directory '#{chroot}' does not contain '/dev/null'") end @@ -311,7 +311,7 @@ def spawn(command) self.dir ||= '/' Dir.chdir self.dir $0 = command - $stdin.reopen '/dev/null' + $stdin.reopen File::NULL if log_cmd $stdout.reopen IO.popen(log_cmd, 'a') else diff --git a/test/test_process.rb b/test/test_process.rb index 32a604ea..f4b50e36 100644 --- a/test/test_process.rb +++ b/test/test_process.rb @@ -116,7 +116,7 @@ def test_valid_should_return_true_with_chroot_and_valid_log File.expects(:exist?).with(@p.chroot).returns(true) File.expects(:exist?).with(@p.log).returns(true) - File.expects(:exist?).with("#{@p.chroot}/dev/null").returns(true) + File.expects(:exist?).with("#{@p.chroot}#{File::NULL}").returns(true) File.stubs(:writable?).with('/foo.log').returns(true)