use strict; use warnings; use IPC::Run qw(run); my($wtr, $rdr, $err); my @cmd = qw(script); my $pid = fork; my $timvariable = 7; unless($pid) { setpgrp; run \@cmd, '>>', "out.txt", '2>>', "err.txt"; } print "Child process id:$pid\n"; for(my $i =0;$i <= $timvariable ; $i++) { sleep(1); print "Parent is waiting to obtain the file which was created by child process\n"; } kill 9,"-$pid"; kill 9,"$pid"; #### #!/usr/bin/perl use POSIX; while(1) { sleep(1); print "I am running\n"; my $pid = fork; print "Process group Id:",getpgrp $pid,"\n"; unless($pid) { while(1) { sleep(2); print "Process group Id in child:",getpgrp getpid(),"\n"; print "I am child and I'am running\n"; } } }