Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^3: Run Perl script in perl program with new process group

by gmargo (Hermit)
on Dec 18, 2009 at 13:55 UTC ( [id://813366]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Run Perl script in perl program with new process group
in thread Run Perl script in perl program with new process group

If you start a job in the foreground (my $cmd = qq{nohup ./perl.pl};), then the process id (PID) and process group (PGRP) will match, because perl will exec the program directly.

If you start a job in the background (my $cmd = qq{nohup ./perl.pl &};), then the process id (PID) and process group (PGRP) will NOT match, because perl notices the shell meta-character '&' and execs a shell directly, and the shell will exec the program. The PGRP you are seeing is the PID of the shell that was started solely to process the backgrounding character.

Since you're already forking, why do you need the implied fork of the '&' character too?

Replies are listed 'Best First'.
Re^4: Run Perl script in perl program with new process group
by veshwar (Initiate) on Dec 18, 2009 at 16:09 UTC
    i need to make the process (my $cmd = qq{nohup ./perl.pl};) a daemon process. if i remove the &, it remains connected with the shell and i cannot disconnect the script. I have tried to start my script in background and starting process without &. It works but the ppid(20753) is still connected to shell which is closing on the logout. $ ps -ef -o "user,pid,ppid,pgid,args" | grep perl.pl userid 22542 20753 22542 /usr/bin/perl ./perl.pl Is there anyway i can change the ppid of this process to 1 without loggingout for the session.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-03-29 15:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found