veshwar has asked for the wisdom of the Perl Monks concerning the following question:
am trying to run a perl script which will internally start a perl process on background and with nohup. which am doing as below in my perl script
My problem is it starts with the parent process group.$cmd = qq(nohup perl.pl &); system($cmd);
I have tried to do the below which is not working
which is not working as expected. Can someone help me in solving this problem or give an idea on how i can proceed.$cmd = qq{nohup perl.pl &}; my $pid = fork(); if($pid == 0) { print STDERR "parent pid=$$ child pid=$pid\n"; }elsif (defined $pid) { print STDERR "child pid=$$ pid=$pid\n"; # Must do setpgrp as child for nohup and job control stuff... setpgrp(0, $$) || die "Cannot do SetGroup\n"; exec "$cmd" || die "Bad exec $!"; }
Update:
In the output we are getting PGRP different from PID 31852 1 31851 18307 /usr/bin/perl ./perl.pl 31854 31852 31851 18307 \_ sleep 1 31852 is different from 31851... i am trying to start the perl.pl in background with PID = PGRP.. if i start the job without Background.. it works as expected but when i start the job on Background(&).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Run Perl script in perl program with new process group
by almut (Canon) on Dec 18, 2009 at 01:48 UTC | |
by veshwar (Initiate) on Dec 18, 2009 at 12:06 UTC | |
by gmargo (Hermit) on Dec 18, 2009 at 13:55 UTC | |
by veshwar (Initiate) on Dec 18, 2009 at 16:09 UTC | |
|
Re: Run Perl script in perl program with new process group
by gmargo (Hermit) on Dec 18, 2009 at 18:51 UTC | |
by veshwar (Initiate) on Dec 18, 2009 at 20:27 UTC |