Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

How do I know my process id, from within perl script

by dominix (Deacon)
on Jan 03, 2004 at 10:05 UTC ( [id://318488]=perlquestion: print w/replies, xml ) Need Help??

dominix has asked for the wisdom of the Perl Monks concerning the following question: (programs and processes)

How do I know my process id, from within perl script

Originally posted as a Categorized Question.

  • Comment on How do I know my process id, from within perl script

Replies are listed 'Best First'.
Re: How do I know my process id, from within perl script
by Anonymous Monk on Jan 03, 2004 at 12:11 UTC

    $$ or $PID

    See perlvar for details.

    (Note that $PID is only available if you use English;)

      And if you're wondering where to grab $PID from, take a look at the English module.

Re: How do I know my process id, from within perl script
by Anonymous Monk on Feb 28, 2004 at 03:19 UTC
    d

    Originally posted as a Categorized Answer.

Re: How do I know my process id, from within perl script
by ack (Deacon) on Sep 19, 2009 at 06:02 UTC

    With respect to Anonymous Monk's response:

    $$ works just fine on my Win32 machine, but $PID fails when use strict is enforced. It fails with the error message:

    Global symbol "$PID" requires explicit package name at MyNewTest05.pl +line 6. Execution of MyNewTest05.pl aborted due to compilation errors.

    That signals to me that $PID is not being set as one of the special Perl variables...at least on my machine. So the OP may need to see which one (if any) of Anonyous Monk's suggested alternatives works for the OP.

      If you've read perlvar you would know $PID is only available when you use English;
Re: How do I know my process id, from within perl script
by Anonymous Monk on May 11, 2004 at 10:57 UTC
    run the system("ps > t") command from the perl script and do a string search for the particular PID required

    Originally posted as a Categorized Answer.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://318488]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2024-04-18 12:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found