Voting

: eight minus three?
(Example: nine)

The Note You're Voting On

jrm456 at speed dot 1s dot fr
10 years ago
Workaround to pcntl_fork() not being usable when PHP is run as an Apache module

function background_job($program, $args)
{
# The following doesn't work when running PHP as an apache module
/*
$pid = pcntl_fork();
pcntl_signal(SIGCHLD, SIG_IGN);

if ($pid == 0)
{
posix_setsid();
pcntl_exec($program, $args, $_ENV);
exit(0);
}
*/

# Workaround
$args = join(' ', array_map('escapeshellarg', $args));
exec("$program $args 2>/dev/null >&- /dev/null &");
}

<< Back to user notes page

To Top