Reputation: 1996
I am running Mac OS X Yosemite.
I am trying to return the PIDs started by a command launch using a background process style. (myCommand &
)
To get them I found $!
which return the PID of the last running process.
Or something like pgrep -f "elm"
which return all the pid with elm
in the command line.
I am wondering if there is a another way to get the PIDs started by a command. Because, I have some programs starting severals processes and $!
only return the last one and using pgrep
could return PID started by another command that the one I want to target.
Edit:
How to get the list of the PIDs started by a command ?
Edit 2:
Edit 3:
Upvotes: 0
Views: 306
Reputation: 2409
Use pidof
.
pidof command
OR
pidof program
OR
pidof [options] program1 program2 ... programN
Upvotes: 1