Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get the PID when a process is started by "system"? 1

Status
Not open for further replies.

julianLiuRsch

Programmer
Oct 4, 2008
11
0
0
If a process is started by ``system'', e.g
---
system "konsole --geometry 650x650+100+0 --workdir /home/julian &";
===
How do we get the PID of this process?

thanks in advance.
 
If I remember - the '&' will spit out a pid when it starts. Maybe the following will work:
Code:
   $os_cmd = "$your_command &";
   open(FH, "$os_cmd |");
   $pid = <FH> ;
   close(FH);
Since the command was started in background mode, the close(FH) should have no effect on it.
 
Sorry - false alarm.
Just tried:
<command> & >pid_file
and
<command> & 2>pid_file

Neither dumped the pid to the file so I doubt my previous post will work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top