Unix BG and Perl/TK
am 23.10.2007 01:05:53 von dodge
I'm not sure if this is the right group to ask or not, but here goes.
I've got a perl/TK script that I need to start in the background.
Since I'm running on Unix, I'd typically do this with:
> myscript.pl &
In this application though, I have another program that is calling my
script. I don't have permission to modify this other program. Is there
a way that I can do the same thing in my script? I've checked the PERL
FAQs, but apparently don't know what I'm looking for. Thanks in
advance!
Re: Unix BG and Perl/TK
am 23.10.2007 04:14:22 von Ben Morrow
Quoth Dodge :
> I'm not sure if this is the right group to ask or not, but here goes.
> I've got a perl/TK script that I need to start in the background.
> Since I'm running on Unix, I'd typically do this with:
>
> > myscript.pl &
>
> In this application though, I have another program that is calling my
> script. I don't have permission to modify this other program. Is there
> a way that I can do the same thing in my script? I've checked the PERL
> FAQs, but apparently don't know what I'm looking for. Thanks in
> advance!
You may want to look at Proc::Daemon.
Ben
Re: Unix BG and Perl/TK
am 23.10.2007 10:52:20 von Joe Smith
Dodge wrote:
> I've got a perl/TK script that I need to start in the background.
> Since I'm running on Unix, I'd typically do this with:
>
>> myscript.pl &
Here's what I use:
$|++ if $debug; # Make sure STDOUT is unbuffered
unless ($debug) { # Become daemon if not debugging
$pid = fork();
die "$0: fork() failed: $!\n" unless defined $pid;
exit if $pid; # Parent exits, child runs detached
chdir('/') || die;
open(STDIN,'
open(STDOUT,'>>/dev/null') || die;
open(STDERR,'>>/dev/null');
}
-Joe