Daemon Win32::Daemon;

P

ph1975

Hi folks,

i created a perl Daemon with Win32::Daemon;
This daemon forks some childs which walk through files and do some
stuff.
After the childs are finished, the parent also dies.
How can i prevent the Parent Process from terminating? The child
invokes a systemcall via system();

The System is Windows 2003 Enterprise Server.

i registered the perl Script in Windows Services and i am starting the
service via the administrative tools -> services.

Thanks a lot,
Philipp



Minimal code exerpt:

use Win32::Daemon;
Win32::Daemon::StartService();
use Proc::Queue;
use POSIX '_exit';

while(1)
{
my $State = Win32::Daemon::State();
if( SERVICE_RUNNING == $State )
{
...


my $pid = fork();
push(@childs,$pid);

if($pid == 0) {

#child
if (-e $taskDirData . "_parsing\\" . $filename) {

$fileExist = " exist: yes";
....
Win32::Daemon::State( SERVICE_RUNNING );

$cmdString =~ s/\\\\/\\\\\\\\/;
# Child-Prozess
my $result = system($cmdString); POSIX::_exit(0);

} else {

$fileExist = " exist: no";

}

} else {

# parent
# waitpid($pid,0);
# SysUtils->debugHandler(5, 0, "I", "Child " . $pid . "
terminated");
Win32::Daemon::State( SERVICE_RUNNING );

}

} # delta
}

.....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top