Skip to content

Commit

Permalink
Replace $$ with Process.pid
Browse files Browse the repository at this point in the history
`Process.pid` is easier to understand.

Signed-off-by: abetomo <[email protected]>
  • Loading branch information
abetomo committed Feb 6, 2023
1 parent cebeed5 commit ede9de8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
16 changes: 8 additions & 8 deletions lib/fluent/supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ def run_rpc_server
# built-in RPC for signals
@rpc_server.mount_proc('/api/processes.interruptWorkers') { |req, res|
$log.debug "fluentd RPC got /api/processes.interruptWorkers request"
Process.kill :INT, $$
Process.kill :INT, Process.pid
nil
}
@rpc_server.mount_proc('/api/processes.killWorkers') { |req, res|
$log.debug "fluentd RPC got /api/processes.killWorkers request"
Process.kill :TERM, $$
Process.kill :TERM, Process.pid
nil
}
@rpc_server.mount_proc('/api/processes.flushBuffersAndKillWorkers') { |req, res|
Expand All @@ -105,8 +105,8 @@ def run_rpc_server
supervisor_sigusr1_handler
stop(true)
else
Process.kill :USR1, $$
Process.kill :TERM, $$
Process.kill :USR1, Process.pid
Process.kill :TERM, Process.pid
end
nil
}
Expand All @@ -115,7 +115,7 @@ def run_rpc_server
if Fluent.windows?
supervisor_sigusr1_handler
else
Process.kill :USR1, $$
Process.kill :USR1, Process.pid
end
nil
}
Expand All @@ -125,7 +125,7 @@ def run_rpc_server
# restart worker with auto restarting by killing
kill_worker
else
Process.kill :HUP, $$
Process.kill :HUP, Process.pid
end
nil
}
Expand All @@ -141,7 +141,7 @@ def run_rpc_server
if Fluent.windows?
supervisor_sigusr2_handler
else
Process.kill :USR2, $$
Process.kill :USR2, Process.pid
end

nil
Expand Down Expand Up @@ -213,7 +213,7 @@ def reload
def install_windows_event_handler
return unless Fluent.windows?

@pid_signame = "fluentd_#{$$}"
@pid_signame = "fluentd_#{Process.pid}"
@signame = config[:signame]

Thread.new do
Expand Down
2 changes: 1 addition & 1 deletion test/command/test_ctl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_commands(data)
Signal.trap(signal) do
got_signal = true
end
Fluent::Ctl.new([command, "#{$$}"]).call
Fluent::Ctl.new([command, Process.pid.to_s]).call
assert_true(got_signal)
end
end
Expand Down
12 changes: 6 additions & 6 deletions test/test_supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def test_main_process_signal_handlers
sv.send(:install_main_process_signal_handlers)

begin
Process.kill :USR1, $$
Process.kill :USR1, Process.pid
rescue
end

Expand Down Expand Up @@ -247,7 +247,7 @@ def test_supervisor_signal_handler
server = DummyServer.new
server.install_supervisor_signal_handlers
begin
Process.kill :USR1, $$
Process.kill :USR1, Process.pid
rescue
end

Expand Down Expand Up @@ -314,10 +314,10 @@ def server.config
$log.out.reset if $log && $log.out && $log.out.respond_to?(:reset)
end

data("Normal", {raw_path: "C:\\Windows\\Temp\\sigdump.log", expected: "C:\\Windows\\Temp\\sigdump-#{$$}.log"})
data("UNIX style", {raw_path: "/Windows/Temp/sigdump.log", expected: "/Windows/Temp/sigdump-#{$$}.log"})
data("No extension", {raw_path: "C:\\Windows\\Temp\\sigdump", expected: "C:\\Windows\\Temp\\sigdump-#{$$}"})
data("Multi-extension", {raw_path: "C:\\Windows\\Temp\\sig.dump.bk", expected: "C:\\Windows\\Temp\\sig.dump-#{$$}.bk"})
data("Normal", {raw_path: "C:\\Windows\\Temp\\sigdump.log", expected: "C:\\Windows\\Temp\\sigdump-#{Process.pid}.log"})
data("UNIX style", {raw_path: "/Windows/Temp/sigdump.log", expected: "/Windows/Temp/sigdump-#{Process.pid}.log"})
data("No extension", {raw_path: "C:\\Windows\\Temp\\sigdump", expected: "C:\\Windows\\Temp\\sigdump-#{Process.pid}"})
data("Multi-extension", {raw_path: "C:\\Windows\\Temp\\sig.dump.bk", expected: "C:\\Windows\\Temp\\sig.dump-#{Process.pid}.bk"})
def test_fluentsigdump_get_path_with_pid(data)
path = Fluent::FluentSigdump.get_path_with_pid(data[:raw_path])
assert_equal(data[:expected], path)
Expand Down

0 comments on commit ede9de8

Please sign in to comment.