Make KILL properly terminate all forked processes#2
Merged
acerv merged 1 commit intolinux-test-project:masterfrom Aug 26, 2025
Merged
Make KILL properly terminate all forked processes#2acerv merged 1 commit intolinux-test-project:masterfrom
acerv merged 1 commit intolinux-test-project:masterfrom
Conversation
If the process we executed with ltx_handle_exec() forks children these did escape the attempt to kill these with ltx_handle_kill() because we only killed the parent, the children were reparented to init and may continue to run happily ever after. Since the parent process was killed we wait() on it and we got stuck in the read() that gets rest of the log from the pipe the stderr and stdout of the executed process is redirected to. That is because the pipe stil has writers active as long as any child process is active. If the main shell on the system was from busybox this happend for any executed command since busybox forks and executes in each case. To fix it, we move the top process in the slot into a seprate process group and the kill command kills a process group rather than a single process. In order to make sure that the process is moved into right process group right after the fork we move it both in the parent and in the child. We need it to move there in the parent in a case that subsequent command is kill and terminate the process before it has a chance to run. We need to make the move in the child because in case it runs before the parent (ltx process) we need the process group right before we may possibly fork any children. Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
acerv
added a commit
to linux-test-project/kirk
that referenced
this pull request
Aug 26, 2025
LTX discovered a bug caused by not setting pid group while new EXEC command are performed. This was causing *_stop tests to fail and it's going to be fixed in the next release. linux-test-project/ltx#2 Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
Member
|
Thanks for fixing this. IMHO a candidate for yet another release bump, let's do it unless you plan to do more fixes soon. |
Collaborator
Yes, this bug requires a new release for sure |
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.
If the process we executed with ltx_handle_exec() forks children these did escape the attempt to kill these with ltx_handle_kill() because we only killed the parent, the children were reparented to init and may continue to run happily ever after. Since the parent process was killed we wait() on it and we got stuck in the read() that gets rest of the log from the pipe the stderr and stdout of the executed process is redirected to. That is because the pipe stil has writers active as long as any child process is active. If the main shell on the system was from busybox this happend for any executed command since busybox forks and executes in each case.
To fix it, we move the top process in the slot into a seprate process group and the kill command kills a process group rather than a single process. In order to make sure that the process is moved into right process group right after the fork we move it both in the parent and in the child.
We need it to move there in the parent in a case that subsequent command is kill and terminate the process before it has a chance to run.
We need to make the move in the child because in case it runs before the parent (ltx process) we need the process group right before we may possibly fork any children.