linux - Store the forked process' id in file -
i have following i'm worried $!
being overwritten prior echo command taking place (i know few milliseconds). how guys recommend going this?
sleep 100 & >/dev/null ; echo $! >sleep.pid
$!
pid of recent background process in current shell, not recent on entire box. useless in practice, because never know if got right value.
the snippet show in question cannot possibly return wrong pid. there no other background process between sleep
, echo
.
Comments
Post a Comment