PDA

View Full Version : Capture a PID as a Variable



Living2007
May 30th, 2012, 05:52 AM
I'm writing a small program which involves a background process. I'm using the "&" attribute with UNIX and it prints the PID, but not in the script. I know it's been stored somewhere, but I want to capture the PID, so when the user want to close the script, the background process is killed by that stored PID!

diesch
May 30th, 2012, 06:09 AM
background_process &
PID="$!"

sisco311
May 30th, 2012, 10:26 AM
http://mywiki.wooledge.org/ProcessManagement

Living2007
June 5th, 2012, 06:12 AM
Awesome, I'll give those a try!!