use strict; use warnings; open FILE, ">x.txt" or die "Cannot create test file: $!"; print FILE "TEXT\n"; close FILE; my $pid = fork(); if ($pid == 0) { # in the child open FC, "x.txt" or print "Can not create file\n"; close FC2; sleep(5); }