use strict; use warnings; if (my $child = fork) { # foreground process sleep 5; kill 9, $child; } else { # background process exec("arecord", "file.wav"); }
The fork plus exec combination allows you to cleanly launch a background process, and gives you the PID for the background process, which can later be passed to kill.
In reply to Re: best way to kill a spawned process
by tobyink
in thread best way to kill a spawned process
by redss
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |