Repository navigation
fluent-ctl: reject 0 and multi-line values as a PID - #5719
Merged
Merged
Conversation
PID 0 makes Process.kill signal the whole process group, so fluent-ctl shutdown 0 killed the shell that ran it. A value like "abc\n123" passed the check too and became 0 in to_i. Signed-off-by: og-orca <301901286+og-orca@users.noreply.github.com>
Watson1978
requested changes
Dec 3, 2026
Watson1978
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the fix. I ran the steps from #5716 on this branch. 0 and $'abc\n123' are rejected now, and the process group keeps running.
I also agree with leaving L95 as it is. With a stricter check there, fluent-ctl shutdown 0 would go to call_winsvc_control_code. That method always opens fluentdwinsvc, whatever name it gets, and asks it to stop.
One regression is left. A PID that ends with a newline is rejected now. Please see the inline comment.
Signed-off-by: og-orca <301901286+og-orca@users.noreply.github.com>
Watson1978
approved these changes
Dec 3, 2026
Watson1978
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the update. A PID that ends with one newline works again. I checked it with the PID file of a running fluentd --daemon. The new row confirms that two newlines are rejected. LGTM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue(s) this PR fixes:
Fixes #5716
What this PR does / why we need it:
fluent-ctl shutdown 0killed the shell that ran it, becauseProcess.killwith PID 0 goes to the whole process group.$'abc\n123'did the same:^and$match per line, so it passed the check andto_imade it 0.L176 uses
/\A[1-9][0-9]*\n?\z/now. It is the regexp from the issue plus one optional trailing newline, so the content of the PID file thatfluentd --daemonwrites can still be passed as is. I ran the steps from the issue, each one in its own session:The issue also names L95, but I left that one alone.
call_winsvc_control_codeopensfluentdwinsvcwhatever name it gets, so with the stricter regexpfluent-ctl shutdown 0on Windows would go that way and ask the real service to stop. Today it only fails to find the eventfluentd_0. That is from reading the code, I didn't run it on Windows.test_invalid_pidgot five more rows. All of them fail on master. A PID with leading zeros like0123is rejected now too.test_pid_with_trailing_newlinechecks that one trailing newline is still accepted.Docs Changes:
None
Release Note:
fluent-ctl: reject 0 and multi-line values as a PID