Daemon Win32::Daemon;

Discussion in 'Perl Misc' started by ph1975@gmail.com, Sep 7, 2006.

  1. Guest

    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
    }

    .....
     
    , Sep 7, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jean-Paul Calderone
    Replies:
    0
    Views:
    457
    Jean-Paul Calderone
    Mar 20, 2009
  2. Floris Bruynooghe
    Replies:
    1
    Views:
    454
    Floris Bruynooghe
    Mar 24, 2009
  3. Bigmac Turdsplash

    win32 service - daemon

    Bigmac Turdsplash, Sep 15, 2009, in forum: Ruby
    Replies:
    5
    Views:
    167
    Bigmac Turdsplash
    Sep 17, 2009
  4. Andre Warnier

    open2(), win2k, perl5.6.1, Win32::Daemon

    Andre Warnier, Sep 10, 2003, in forum: Perl Misc
    Replies:
    0
    Views:
    109
    Andre Warnier
    Sep 10, 2003
  5. Replies:
    1
    Views:
    135
    robic0
    Apr 30, 2006
Loading...

Share This Page