Merge pull request #223 from jygaulier/fix895

fix issue 895 (scheduler creates zombies)
This commit is contained in:
Romain Neutron
2012-09-27 01:41:10 -07:00
3 changed files with 21 additions and 14 deletions

View File

@@ -54,6 +54,7 @@ class task_Scheduler
*/
public function run()
{
$appbox = appbox::get_instance(\bootstrap::getCore());
$registry = $appbox->get_registry();
@@ -71,6 +72,9 @@ class task_Scheduler
}
if (function_exists('pcntl_fork')) {
// avoid <defunct> php when a task ends
pcntl_signal(SIGCHLD, SIG_IGN);
$this->method = self::METHOD_FORK;
}

View File

@@ -187,7 +187,6 @@ class task_period_cindexer extends task_abstract
parent.calccmd();
</script>
<?php
return("");
} else { // ... so we NEVER come here
// bad xml
@@ -222,13 +221,12 @@ class task_period_cindexer extends task_abstract
if(user.value)
cmd += " -u=" + user.value;
if(password.value)
cmd += " -p=" + password.value;
cmd += " -p=xxxxxx"; // + password.value;
if(socket.value)
cmd += " --socket=" + socket.value;
if(charset.value)
cmd += " --default-character-set=" + charset.value;
if(use_sbas.checked)
cmd += " -o";
cmd += " -o";
if(nolog.checked)
cmd += " -n";
if(clng.value)
@@ -257,7 +255,6 @@ class task_period_cindexer extends task_abstract
}
</script>
<?php
return;
}
@@ -324,7 +321,6 @@ class task_period_cindexer extends task_abstract
<div style="margin:10px; padding:5px; border:1px #000000 solid; font-family:monospace; font-size:16px; text-align:left; color:#00e000; background-color:#404040" id="cmd">cmd</div>
</center>
<?php
return ob_get_clean();
}
@@ -395,16 +391,14 @@ class task_period_cindexer extends task_abstract
}
if ($this->password) {
$args[] = '-p=' . $this->password;
$args_nopwd[] = '-p=******';
$args_nopwd[] = '-p=xxxxxxx';
}
if ($this->socket) {
$args[] = '--socket=' . $this->socket;
$args_nopwd[] = '--socket=' . $this->socket;
}
if ($this->use_sbas) {
$args[] = '-o';
$args_nopwd[] = '-o';
}
$args[] = '-o';
$args_nopwd[] = '-o';
if ($this->charset) {
$args[] = '--default-character-set=' . $this->charset;
$args_nopwd[] = '--default-character-set=' . $this->charset;
@@ -460,9 +454,18 @@ class task_period_cindexer extends task_abstract
$pipes = array();
$this->log(sprintf('cmd=\'%s %s\'', $cmd, implode(' ', $args_nopwd)));
$logcmd = $cmd;
foreach ($args_nopwd as $arg) {
$logcmd .= ' ' . escapeshellarg($arg);
}
$process = proc_open($cmd . ' ' . implode(' ', $args), $descriptors, $pipes, $this->binpath, null, array('bypass_shell' => true));
$this->log(sprintf('cmd=\'%s\'', escapeshellcmd($logcmd)));
$execmd = $cmd;
foreach ($args as $arg) {
$execmd .= ' ' . escapeshellarg($arg);
}
$process = proc_open(escapeshellcmd($execmd), $descriptors, $pipes, $this->binpath, null, array('bypass_shell' => true));
$pid = NULL;
if (is_resource($process)) {