[cc lang="php"]
$pid = pcntl_fork();
if ($pid == -1) {
die('could not fork');
} else if ($pid) {
// we are the parent
pcntl_wait($status); //Protect against Zombie children
} else {
// we are the child
echo "download files ...\n";
$cmd = "/usr/bin/wget --user-agent=\"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;)\" \\
--header=\"Accept:text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\" \\
--header=\"Accept-Language: en-us,en;q=0.5\" \\
--header=\"Accept-Encoding: gzip,deflate\" \\
--header=\"Accept-Charset: GBK,utf-8;q=0.7,*;q=0.7\" \\
--header=\"Keep-Alive: 300\" -O /dev/null -i list.txt -o wget.log";
exec($cmd);
echo "done\n";
declare(ticks = 1);
pcntl_signal(SIGUSR1, function ($signal) {
echo 'HANDLE SIGNAL ' . $signal . PHP_EOL;
});
posix_kill(posix_getpid(), SIGUSR1);
die();
}
[/cc]
No comments:
Post a Comment