-
Notifications
You must be signed in to change notification settings - Fork 20
smoke: fix running grout in a separate terminal #349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
When grout is started manually in a separate terminal, pgrep -g0 grout returns nothing and exits with an error status. Indeed, there is no grout process started as a child of the shell script. Only check for the PID if grout was started by the script. Fixes: 6a7e9a4 ("smoke: print stack traces on crashes") Signed-off-by: Robin Jarry <[email protected]>
📝 WalkthroughWalkthroughThe change adds a conditional guard to the grout PID retrieval in Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Single-file change with straightforward conditional logic wrapping an existing command. No complex branching, state management, or side effects to verify. Possibly related PRs
Suggested reviewers
Pre-merge checks✅ Passed checks (3 passed)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.sh⚙️ CodeRabbit configuration file
Files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
socat FILE:/dev/null UNIX-CONNECT:$GROUT_SOCK_PATH,retry=10 | ||
grout_pid=$(pgrep -g0 grout) | ||
if [ "$run_grout" = true ]; then | ||
grout_pid=$(pgrep -g0 grout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we get the process ID of the grout process directly when we create it ?
We put the process in the background with "&" just above with "taskset ..." but then we can use :
grout_pid=$!
to capture it no ?
($!) Expands to the process ID of the job most recently placed into the background,
https://www.gnu.org/software/bash/manual/html_node/Special-Parameters.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$!
returns the PID of the last background "job" that was created. Which isn't necessarily the grout process itself (there may be a taskset parent, or in case of a pipeline, the PID may point to grep
or awk
). I wanted to make sure we get the correct process ID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah ok if we are sure that there is no other grout process running this will work properly - otherwise it will output a list of pid like '12324 34456'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is the point of the -g0 argument:
-g, --pgroup pgrp,...
Only match processes in the process group IDs listed. Process group 0 is translated into pgrep's own process group.
When grout is started manually in a separate terminal, pgrep -g0 grout returns nothing and exits with an error status. Indeed, there is no grout process started as a child of the shell script.
Only check for the PID if grout was started by the script.
Fixes: 6a7e9a4 ("smoke: print stack traces on crashes")
Summary by CodeRabbit