#!/usr/bin/perl use strict; use warnings; my $cmd = qq{nohup ./perl.pl &}; my $pid = fork; die 'fork failed' unless defined $pid; if ($pid) { print STDERR "parent pid=$$ child pid=$pid\n"; wait; my $sid = getppid; system "ps f -s $sid -o pid,ppid,pgrp,sid,cmd"; } else { print STDERR "child pid=$$ \$pid=$pid\n"; setpgrp; exec $cmd or die "Bad exec: $!"; }