#!/usr/bin/perl use warnings; use strict; if (-f "./testfile") { !system "rm -f testfile" or die "Couldn't delete already present testfile\n"; } my $pid; my $parent = $$; open (INFILE, "+>testfile") or die "Can't create testfile: $!"; print "This is parent $parent \n"; defined($pid = fork) or die "Cannot fork: $!"; unless($pid) { # Child process is here print "This is child pid $$\n"; exec "cat /dev/urandom > testfile"; } sleep 1; close INFILE; kill -9 => $pid;