Do You PHP はてブロ

Do You PHPはてなからはてブロに移動しました

--enable-sigchildを付けるとpclose関数で-1が返る

via. php.internals: Re: phpize returns -1

ちょっと気になったネタ。


> Could someone fix phpize to make it return 0 on success? It always
> returns -1 when opened via proc_open(), which is exceedingly annoying
> when you're trying to use it in a PHP script.
>
> Thanks,
> Greg
>

The bottom of phpize does return 0 and should be reached when all
works OK. I looked into a similar problem a while back.

Are you seeing a signal handling issue like http://bugs.php.net/bug.php?id=8992 ?
I still see pclose() return failure when I use --enable-sigchild. See
http://blogs.oracle.com/opal/2009/03/php_oci8_signal_handling_and_e_1.html

この件、#8992以外にも#37074としても登録されていますが、StatusがNo Feedbackで止まってるようです。

で、PHP5.2.9 on CentOS5.2で実際に試してみました。configureオプションは

./configure  \
--with-apxs2=/usr/sbin/apxs \
--prefix=/usr/local/lib/php5 \
--with-config-file-path=/usr/local/lib/php5/ini/5.2.9 \
--with-config-file-scan-dir=/usr/local/lib/php5/ini.d \
--with-pear=/usr/local/lib/php5/pear \
--enable-zend-multibyte \
--enable-mbstring \
--enable-dom \
--enable-filter=shared \
--with-gettext=shared \
--with-mcrypt=shared \
--with-gd=shared \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir \
--with-ttf \
--with-freetype-dir \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--enable-soap=shared \
--enable-pdo=shared \
--with-pdo-sqlite=shared \
--with-sqlite=shared \
--enable-sqlite-utf8 \
--with-openssl=shared \
--with-curl=shared \
--enable-bcmath=shared \
--enable-pcntl=shared \
--enable-sockets=shared \
--with-xsl=shared \
--enable-zip=shared \
--with-bz2=shared \
--with-mysql=shared \
--with-pdo-mysql=shared \
--with-pdo-pgsql=shared \
--with-pgsql=shared \
--with-zlib=shared \
--disable-ipv6 \
--with-readline

と、最後に--enable-sigchildを付けたものの2種類。

確認対象は、

  • peclコマンドを使ったPECLのインストール(phpizeを実行させる)
$ sudo pecl install -a phar-2.0.0RC1
$ cat pclose.php
<?php
$handle = popen('/bin/ls', 'r');
var_dump(pclose($handle));
$

です。

結果ですが、

--enable-sigchildを付けない場合

  • peclコマンドで問題なくインストールできた
    • 3パッケージ分のphpize後にconfigure、make、make installまで完了
  • スクリプトの戻り値は"0"

--enable-sigchildを付けた場合

  • phpizeに失敗し、インストールできない
$ sudo pecl install -a phar-2.0.0RC1
              :
running: phpize
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519
ERROR: `phpize' failed
$ 

となりました。


ちなみに、何で気になったかは、pecl installでの「`phpize' failed」 - Do You PHP はてなを参照。当時は、oci8+Oracle Instant Clientをインストールしていたので、configureオプションに--enable-sigchildを使ってたんですよね。今はoci8を使ってないので、--enable-sigchildは指定してません。

うーん。これだったか。。。どうりで、最近phpizeに失敗しなかったわけだ。


ついでに。
php.internals: Re: phpize returns -1で返信しているChristopher Jones氏によると、oci8と--enable-sigchildの組み合わせを盲目的に指定するのではなくて、


Only if you see defunct "zombie" Oracle server processes then start PHP/Apache with the Oracle Net option BEQUEATH_DETACH=YES in your sqlnet.ora, or, to keep the setting specific to PHP, set your environment starting Apache:

export BEQUEATH_DETACH=YES

If this doesn't help, then consider building PHP with --enable-sigchild.

ということのようです。--enable-sigchildは「最後の手段」ということですかね。