Re: How to capture pid

From: Harry Putnam (reader_at_newsguy.com)
Date: 03/03/04


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.



Relevant Pages

  • [RFC] "biological parent" pid
    ... So I made up the "biological parent pid" bioppid (in contrast to the ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Re: How to get Parent Pid from Kernel Driver?
    ... NtQuerySystemInformation, I do not see any way to get the Parent Pid. ... ULONG pid, now; ...
    (microsoft.public.win32.programmer.kernel)
  • Re: How to capture pid
    ... you are getting the parent pid in the perl script. ... you are doing an exec. ...
    (perl.beginners)
  • Re: How to capture pid
    ... >actual sample script" ... you are getting the parent pid in the perl script. ...
    (perl.beginners)
  • Re: Possible "struct pid" leak from tty_io.c
    ... put_pid twice for pid 245 (the unresolved leak) and get_pid for pid ... With my current foggy recollections of the semantics of how SIGHUP is ... the tty and don't send SIGHUP to the old users of the tty. ...
    (Linux-Kernel)