Fix journalctl process lifecycle and cleanup bugs#49528
Draft
belimawr wants to merge 42 commits intoelastic:mainfrom
Draft
Fix journalctl process lifecycle and cleanup bugs#49528belimawr wants to merge 42 commits intoelastic:mainfrom
belimawr wants to merge 42 commits intoelastic:mainfrom
Conversation
- Set timezone to match host - Add systemd 242 - use absolute path for journald.conf
Kill() previously only sent SIGKILL and returned immediately, leaving the stdout/stderr reader goroutines and the process-wait goroutine still running. This meant Close() could return before cleanup finished, potentially leaking goroutines. Kill() now calls waitDone.Wait() after sending SIGKILL, blocking until all background goroutines have exited and the process has been reaped. GenAI-Assisted: Yes Human-Reviewed: Yes Tool: Cursor-CLI, Model: Claude 4.6 Opus (Thinking)
When journalctl exits on its own (crash or short-lived commands like --version), Kill() returned "process already finished" which Close() propagated as a misleading error. Swallow os.ErrProcessDone since the process is already gone and cleanup via waitDone.Wait() still runs.
The readersWG fix ensures cmd.Wait() is only called after the reader goroutines finish, so the pipe can no longer be closed while readers are active. The fs.PathError branch handling "file already closed" is now unreachable. Replace it with a simple non-EOF error log, matching the stderr reader. GenAI-Assisted: Yes Human-Reviewed: Yes Tool: Cursor-CLI, Model: Claude 4.6 Opus (Thinking)
The factory error paths returned &journalctl{}, a non-nil pointer to
an unusable struct. Because the return type is the Jctl interface, this
value appears non-nil to callers, defeating nil checks and panicking
on any method call. Return nil so the interface value is a true nil.
GenAI-Assisted: Yes
Human-Reviewed: Yes
Tool: Cursor-CLI, Model: Claude 4.6 Opus (Thinking)
Contributor
🤖 GitHub commentsJust comment with:
|
Contributor
|
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
When Kill was called, if the stdout reader goroutine was trying to send on the channel and nobody was listening, the goroutine would get stuck and Kill would block forever. This commit fixes it by using a channel to notify this goroutine to return when Kill is called.
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.
Proposed commit message
Checklist
I have made corresponding changes to the documentationI have made corresponding change to the default configuration filesI have added tests that prove my fix is effective or that my feature works. Where relevant, I have used thestresstest.shscript to run them under stress conditions and race detector to verify their stability../changelog/fragmentsusing the changelog tool.## Disruptive User Impact## Author's ChecklistHow to test this PR locally
Run the Journald input tests:
Related issues
--boot all#49445## Use cases## Screenshots## Logs