merged branch romainneutron/termsig (PR #7865)

This PR was merged into the 2.1 branch.

Discussion
----------

[Process] Fix #5594 : `termsig` must be used instead of `stopsig` in exceptions when a process is signaled

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #5594
| License       | MIT

When a process is signaled, an exception is thrown saying `The process has been signaled with signal "0".`. This is wrong because "0" is not a signal.

This is actually a bug in `Process` because we retrieve the `stopsig` property of the process status whereas we should retrieve the `termsig`.

`stopsig` should be retrieved in case the process has been stopped, and `termsig` when it has been signaled, see [PHP documentation](http://www.php.net/manual/en/function.proc-get-status.php).

Commits
-------

8757ad4 [Process] Fix #5594 : `termsig` must be used instead of `stopsig` in exceptions when a process is signaled
This commit is contained in:
Fabien Potencier 2013-04-29 09:14:50 +02:00
commit 372a76a453
1 changed files with 8 additions and 2 deletions

View File

@ -398,7 +398,10 @@ class Process
}
$this->updateStatus();
if ($this->processInformation['signaled']) {
throw new \RuntimeException(sprintf('The process stopped because of a "%s" signal.', $this->processInformation['stopsig']));
if ($this->isSigchildEnabled()) {
throw new RuntimeException('The process has been signaled.');
}
throw new RuntimeException(sprintf('The process has been signaled with signal "%s".', $this->processInformation['termsig']));
}
$time = 0;
@ -410,7 +413,10 @@ class Process
$exitcode = proc_close($this->process);
if ($this->processInformation['signaled']) {
throw new \RuntimeException(sprintf('The process stopped because of a "%s" signal.', $this->processInformation['stopsig']));
if ($this->isSigchildEnabled()) {
throw new RuntimeException('The process has been signaled.');
}
throw new RuntimeException(sprintf('The process has been signaled with signal "%s".', $this->processInformation['termsig']));
}
$this->exitcode = $this->processInformation['running'] ? $exitcode : $this->processInformation['exitcode'];