File: test-fork-daemon

package info (click to toggle)
libapp-daemon-perl 0.22-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 204 kB
  • sloc: perl: 371; makefile: 8
file content (29 lines) | stat: -rwxr-xr-x 402 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/local/bin/perl -w
use strict;
use Log::Log4perl qw(:easy);

     # Program:
use App::Daemon qw( daemonize );
daemonize();

my $pid = fork();

if( !defined $pid ) {
    die "fork failed";
} 

if( $pid ) {
    # parent
    
} else {
    # child
    INFO "child exits";
    die "Aiieeeeeh";
}

waitpid $pid, 0;
INFO "parent waitpid done";
  
INFO "parent sleep";
sleep(100);
INFO "parent exiting";