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

RE: pidof a process

Thread Previous
From:
Bob Showalter
Date:
February 7, 2002 08:01
Subject:
RE: pidof a process
Message ID:
2E4528861499D41199D200A0C9B15BC031B804@taylorwhite.com
> -----Original Message-----
> From: Jorge Goncalvez [mailto:goncal11@col.bsf.alcatel.fr]
> Sent: Thursday, February 07, 2002 10:51 AM
> To: beginners@perl.org
> 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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About