use Apache::SubProcess; defined (my $kid = fork) or die "Cannot fork: $!\n"; if ($kid) { # Parent runs this block } else { # Child runs this block $r->cleanup_for_exec(); # untie the socket chdir '/' or die "Can't chdir to /: $!"; close STDIN; close STDOUT; close STDERR; # some code goes here CORE::exit(0); } # possibly more code here usually run by the parent