#!/usr/bin/env perl use strict; my $pid = fork(); if ($pid == 0){ # child print "Testing daemon\n"; my $child = fork(); if ($child == 0) { # grandchild open TEST, ">", "$ENV{HOME}/daemon.test" or exit 2; my $i = 0; while ($i < 10){ print TEST "Alive\n"; sleep 5; } close TEST; exit 0; } print "Exiting child\n"; print "Grandchild PID is $child\n"; exit 0; } # parent print "Parent process is $$: Child is $pid\n"; print "Exiting Parent\n"; exit 0;