List,
I have read and understood as much as I can about fork. But I have the
following problem where I need to start up a second script in my first
script. Problem is, if I have one already started as a deamon the
second won't start as a deamon. Am I doing something terribly wrong
here?
This is the first script... script1
deamonize();
sub daemonize {
chdir '/var/daemon2' or die "Can't chdir to /var/daemon: $!";
open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
open STDOUT, '>>/dev/null' or die "Can't write to /dev/null: $!";
open STDERR, '>>/dev/null' or die "Can't write to /dev/null: $!";
defined(my $pid = fork) or die "Can't fork: $!";
exit if $pid;
setsid or die "Can't start a new session: $!";
umask;
}
While(1) {
if (this == that) {
exec("perl_script2.pl"); #??? And continue the while
loop as a daemon <----
} else {
#Continue
}
}
This is the second script... script2
deamonize();
sub daemonize {
chdir '/var/daemon2' or die "Can't chdir to /var/daemon: $!";
open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
open STDOUT, '>>/dev/null' or die "Can't write to /dev/null: $!";
open STDERR, '>>/dev/null' or die "Can't write to /dev/null: $!";
defined(my $pid = fork) or die "Can't fork: $!";
exit if $pid;
setsid or die "Can't start a new session: $!";
umask;
}
While(1) {
if (this == that) {
print "hello world! \n";
} else {
#Continue
}
}
==============================
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email: [EMAIL PROTECTED]
WWW: http://www.vintek.net
Tel: (08) 8523 5035
Fax: (08) 8523 2104
Snail: P.O. Box 312
Gawler SA 5118
==============================
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]