[kwlug-disc] Parent Processes

Colin Mackay zixiekat at gmail.com
Tue Jan 25 12:46:17 EST 2011


Ah!  /proc/<PID>/status and look for 1 under PPid:, when you find all the
ones that have to do with search.pl and have a 1 for PPid, we're all set.

Thanks. :)


On Tue, Jan 25, 2011 at 12:21 PM, John Van Ostrand <john at netdirect.ca>wrote:

> A simple answer is to check /proc/<pid> for the parent pid and recurse.
> Eventually it will be 1 and that's the top process.
>
> ------------------------------
>  *From*: kwlug-disc-bounces at kwlug.org
> *To*: KWLUG discussion
> *Sent*: Tue Jan 25 12:13:33 2011
> *Subject*: [kwlug-disc] Parent Processes
> Greetings,
>
> I've been wrestling to find the parent process of perl scripts that are
> left running after exiting from the parent shell.  Specifically it is a
> search script that is started like this:
>
> nohup search.pl -o output.txt -p <pattern> &
>
> Following this, I exit the shell.  From another shell, running pstree, I
> can see:
>
> search.pl, 12345 ....
>     |--search.pl, 12346 ....
>     |--search.pl, 12347
>
> ...up to about 20 times, which is how the script runs.
>
> But if more than one search is running, I of course see this twice, with
> different pids.
>
> search.pl, 12345 ....
>     |--search.pl, 12346 ....
>     |--search.pl, 12347....
>
> search.pl, 3454 ....
>     |--search.pl, 3455 ....
>     |--search.pl, 3456....
>
>
> What I'd like to find, with a bash script, is the parent process to these.
> It's easy to type in pstree, but I'd like the pid as a variable, but I'm
> having a hard time figuring out a shell command that will help me find
> these...
>
>
> Any ideas out there?
>
> _______________________________________________
> kwlug-disc mailing list
> kwlug-disc at kwlug.org
> http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://kwlug.org/pipermail/kwlug-disc_kwlug.org/attachments/20110125/76349561/attachment.htm>


More information about the kwlug-disc mailing list