use strict; use warnings; if (my $child = fork) { # foreground process sleep 5; kill 9, $child; } else { # background process exec("arecord", "file.wav"); }