cvs: pear /Crypt_GPG/GPG/Driver Php.php
| From: | Michael Gauthier | Date: | Sat, 05 Apr 2008 00:45:49 +0000 |
| Subject: | cvs: pear /Crypt_GPG/GPG/Driver Php.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-51799@lists.php.net to get a copy of this message | ||
gauthierm Sat Apr 5 00:45:49 2008 UTC
Modified files:
/pear/Crypt_GPG/GPG/Driver Php.php
Log:
Clean up exit code parsing from proc_close(). It returns a termination status, not an exit code.
http://cvs.php.net/viewvc.cgi/pear/Crypt_GPG/GPG/Driver/Php.php?r1=1.21&r2=1.22&diff_format=u
Index: pear/Crypt_GPG/GPG/Driver/Php.php
diff -u pear/Crypt_GPG/GPG/Driver/Php.php:1.21 pear/Crypt_GPG/GPG/Driver/Php.php:1.22
--- pear/Crypt_GPG/GPG/Driver/Php.php:1.21 Fri Mar 28 18:34:00 2008
+++ pear/Crypt_GPG/GPG/Driver/Php.php Sat Apr 5 00:45:49 2008
@@ -32,7 +32,7 @@
* @author Michael Gauthier <mike@silverorange.com>
* @copyright 2005-2007 silverorange
* @license http://www.gnu.org/copyleft/lesser.html LGPL
License 2.1
- * @version CVS: $Id: Php.php,v 1.21 2008/03/28 18:34:00 gauthierm Exp $
+ * @version CVS: $Id: Php.php,v 1.22 2008/04/05 00:45:49 gauthierm Exp $
* @link http://pear.php.net/package/Crypt_GPG
* @link http://www.gnupg.org/
*/
@@ -1368,16 +1368,23 @@
$this->_closePipe($pipe_number);
}
- $return_value = proc_close($this->_process);
+ $termination_status = proc_close($this->_process);
- if ($return_value != 0) {
- $this->_debug("Subprocess returned an unexpected value: " .
- $return_value);
+ // proc_close returns a termination status, not exit code
+ if (($termination_status & 0x7f) == 0) { // WIFEXITED
+ $exit_code = ($termination_status & 0xff) >> 8; // WEXITSTATUS
+ } else {
+ $exit_code = -1;
+ }
+
+ if ($exit_code != 0) {
+ $this->_debug('Subprocess returned an unexpected exit code: ' .
+ $exit_code);
$this->_debug("Error text is:\n" . $error);
$this->_debug("Status text is:\n" . $status);
- $return = $this->_getErrorCode($return_value, $error, $status);
+ $return = $this->_getErrorCode($exit_code, $error, $status);
}
$this->_process = null;
@@ -1560,17 +1567,17 @@
* {@link http://www.gnupg.org/download/ GPG
distribution} for info on
* GPG's output when --status-fd is specified.
*
- * @param integer $return_value the error code returned by the GPG
- * subprocess.
- * @param string $error the GPG subprocess output to stderr.
- * @param string $status the GPG subprocess output to the
- * --status-fd file descriptor.
+ * @param integer $exit_code the error code returned by the GPG
+ * subprocess.
+ * @param string $error the GPG subprocess output to stderr.
+ * @param string $status the GPG subprocess output to the --status-fd
+ * file descriptor.
*
* @return integer the specific error code for the GPG subprocess error.
* If no specific exception is known,
* {@link Crypt_GPG::ERROR_UNKNOWN} is returned.
*/
- private function _getErrorCode($return_value, $error, $status)
+ private function _getErrorCode($exit_code, $error, $status)
{
$error_code = Crypt_GPG::ERROR_UNKNOWN;