develooper Front page | perl.beginners | Postings from February 2002

RE: pidof a process

Thread Previous
Bob Showalter
February 7, 2002 08:01
RE: pidof a process
Message ID:
> -----Original Message-----
> From: Jorge Goncalvez []
> Sent: Thursday, February 07, 2002 10:51 AM
> To:
> Subject: RE:pidof a process
> Hi, Iw onder if there is a way to obtain the PID of a process 
> with perl?
> Thanks.

Do you mean your perl process? It's in the $$ variable.

getppid() will return the PID of your process' parent.

To get the id's of your children, you need to save the
return values from fork() or pipe open().

To get the PID of an unrelated process is an OS-specific
task, AFAIK. Some processes write their PID to a file. Or
you can examine the output of ps(1) or the like.

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About