Skip to content

Commit

Permalink
style: Suppress Style/FileNull cop
Browse files Browse the repository at this point in the history
  • Loading branch information
mishina2228 committed Dec 28, 2024
1 parent 282a78e commit 8af6f91
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/god/cli/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions lib/god/process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/test_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 8af6f91

Please sign in to comment.