Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion smoke/_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ if [ "$run_grout" = true ]; then
taskset -c 0,1 grout -tvvx $grout_extra_options &
fi
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)
Copy link
Collaborator

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

Copy link
Collaborator Author

@rjarry rjarry Oct 21, 2025

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.

Copy link
Collaborator

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'

Copy link
Collaborator Author

@rjarry rjarry Oct 21, 2025

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.

fi

case "$(basename $0)" in
config_test.sh|graph_svg_test.sh)
Expand Down