#!/usr/bin/perl use warnings; use strict; $| = 1; # need either this or to explicitly flush stdout, etc. # before forking print "Content-type: text/plain\n\n"; print "Going to start the fork now\n"; if ( !defined(my $pid = fork())) { print STDERR "fork error\n"; exit(1); } elsif ($pid == 0) { # child close(STDOUT);close(STDIN);close(STDERR); exec('./fork-long-process-test-process'); # lengthy processing } else { # parent print "forked child \$pid= $pid\n"; exit 0; }