Warning: If you're reading a command with infinite output, such as 'vmstat 2', pclose will cause the script to hang. This is because pclose waits for the command to exit, in order to return the exit status. If the process never exits, pclose never returns.
pclose
(PHP 4, PHP 5)
pclose — Cierra un apuntador de archivo de proceso
Descripción
int pclose
( resource $gestor
)
Cierra un apuntador de archivo a un pipe abierto por popen().
Lista de parámetros
- gestor
-
El apuntador de archivo debe ser válido, y debe haber sido devuelto por un llamado satisfactorio a popen().
Valores retornados
Devuelve el status de terminación del proceso que fue ejecutado.
pclose
chad 0x40 herballure 0x2e com
04-Sep-2007 11:16
04-Sep-2007 11:16
kcross at nssolutions dot com
17-Jul-2003 12:08
17-Jul-2003 12:08
Somewhere between 4.1.1 and 4.2.3, the return value from pclose changed.
The exit status used to be in the second byte, so that the status would be (pclose($fp)/256).
It is now in the low-order byte, so the status is just pclose($fp).
Be careful.
vdweij at mailsurf dot com
12-Mar-2003 05:18
12-Mar-2003 05:18
As I understand pclose will return 0 (on every platform) in case popen could not execute the specified command.
Since popen only returns the status wether it was able to send a command and not wether it was succesfully executed. Only the returned value of pclose can be used to check wether a command could be executed.
roel at bouwman dot net
07-Oct-1999 07:23
07-Oct-1999 07:23
The return value of pclose() is not the exit status of the program, but a value as returned by waitpid() of wait4().
To obtain the exit status:
$ret=(pclose($f)>>8)&0xFF;
