Intro: I have a daemon, which spawn processes and I have to stop it all gracefully. The solution I found on web based on pgid:

group_id=$(ps -o pgid= $(cat $pidfile))
if [ ! -z $group_id ]; then
        kill -- -$group_id

I was wondered how it works. And the first thing which I got stuck with is getting group_id. I can't get what's going here:

$ ps -o pgid= 21814

$ ps -o pgid=21814

But it seems, like I really need that first example with space after "=":

$ pstree -p | grep 21814

Can anyone explain what's going on here? What I get as output of that examples?

1 Answer 1


The equal symbol following a format flag (-o format) suppress the printing of the header that names the columns of option produced as the output. This enables testing for null (empty) results.

By default, ps selects all processes with the same effective user ID as the current user of the terminal session. Specifying the PID of interest after the = symbol infers that the header line contains that PID. The other processes reported are those for you terminal session --- bash and the ps process itself. You can see this if you do:

ps -o comm,pgid=21814

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.