Re: How to capture pid
From: Harry Putnam (reader_at_newsguy.com)
Date: 03/03/04
- Next message: Wc -Sx- Jones: "Re: *_checks before /etc/aliases?"
- Previous message: James Edward Gray II: "Re: listing prime numbers in a range (Beginning Perl exercise)"
- In reply to:(deleted message) Zentara: "Re: How to capture pid"
- Next in thread: Zentara: "Re: How to capture pid"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: beginners@perl.org Date: Wed, 03 Mar 2004 10:36:06 -0600
zentara <zentara@highstream.net> writes:
> On Tue, 02 Mar 2004 18:07:58 -0600, reader@newsguy.com (Harry Putnam)
> wrote:
>>
>>For some reason the pid printed does not match the output of ps:
>>
>>actual sample script"
>>
>>Note the script outputs 15173 and ps shows 30335
>>
>>Do you have an idea what is happening here?
>
> Yeah, you are getting the parent pid in the perl script.
> When you try to use system or exec to start another
> process, perl gets the pid of the very first part of the whole
> transaction, which is usually the pid of the xterm or the
> bash shell which will run your command with a second pid.
> It usually works ok, because when you kill the parent pid,
> it's children get killed too, so we hardly ever have to deal
> with them being different.
If you want to log it for SIGHUP in /var/run/process.pid would the
parent work as well?
> Use Proc::ProcessTable to get the pid of your program name.
> Here is an example:
---8<snip script
Not sure I understand what I'm supposed to be seeing.
None of this output resembles a pid.
I shortened the count up to 10 and watched it output to STDOUT and
to a separate tty... output
STDOUT
1
2
3
[...]
other TTY
1a
2a
3a
[...]'
NOt sure I get what this has to do with two pids involved.
- Next message: Wc -Sx- Jones: "Re: *_checks before /etc/aliases?"
- Previous message: James Edward Gray II: "Re: listing prime numbers in a range (Beginning Perl exercise)"
- In reply to:(deleted message) Zentara: "Re: How to capture pid"
- Next in thread: Zentara: "Re: How to capture pid"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|