plugins: in_exec: don't eat last character of plugin output #4655
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.
Notes : This is a backport of @rschwebel's PR #4496 so I'm reproducing his
PR comment. I don't know if there's a way to tag and credit him so if anyone
knows how to feel free to do so.
The plugin works if the execed command outputs a trailing newline,
because in that case that newline is replaced by the clamping \0.
However, when the command does not print a trailing newline, the last
character is overwritten.
This can be tested with:
[INPUT]
Name exec
Tag exec_adc
Command echo -n '{"foo": "bar"}'
Parser json
Interval_Sec 5
Interval_NSec 0
Buf_Size 8mb
With "-n" in the Command line, we end up with
[2021/12/01 03:11:44] [error] [input:exec:exec.0] parser returned an error
without this patch.
Fixes: #4493