in reply to Re^2: Advice: Async Options for fire-and-forget subroutine
in thread Advice: Async Options for fire-and-forget subroutine
Untested simplistic pseudocode that ignores a potential error point (0 == fork() is for the child side of the fork and it's not tested here). Forked processes are regular processes on *nix, just children of the original program.
$SIG{CHLD} = "IGNORE"; while ( program_should_be_running() ) { # Might want a sleep or a usleep (from Time::HiRes) here. if ( my $pid = fork ) { # Do nothing...? This is the "permanent" parent process. # $pid is the child $$ } else { run_your_sub(); # Processes could stack up fast. } }
|
|---|