You can use the ppid of the parent by echoing out the BASHPID of the parent when you first enter
the shell,then you background the process and can look up the pid via ppid using the parent pid.
E.g. To get the pid of a sleep 555 command backgrounded within a subshell:
(echo "$BASHPID" > /tmp/_tmp_pid_ && sleep 555 &) && ps -ho pid --ppid=$(< /tmp/_tmp_pid_)
No comments:
Post a Comment