Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : Filesystem Functions : pclose

pclose

Closes process file pointer (PHP 4, PHP 5)
int pclose ( resource handle )


Related Examples ( Source code ) » pclose



Code Examples / Notes » pclose

chad 0x40 herballure 0x2e com

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.

roel

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;


kcross

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

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.


Change Language


Follow Navioo On Twitter
basename
chgrp
chmod
chown
clearstatcache
copy
delete
dirname
disk_free_space
disk_total_space
diskfreespace
fclose
feof
fflush
fgetc
fgetcsv
fgets
fgetss
file_exists
file_get_contents
file_put_contents
file
fileatime
filectime
filegroup
fileinode
filemtime
fileowner
fileperms
filesize
filetype
flock
fnmatch
fopen
fpassthru
fputcsv
fputs
fread
fscanf
fseek
fstat
ftell
ftruncate
fwrite
glob
is_dir
is_executable
is_file
is_link
is_readable
is_uploaded_file
is_writable
is_writeable
lchgrp
lchown
link
linkinfo
lstat
mkdir
move_uploaded_file
parse_ini_file
pathinfo
pclose
popen
readfile
readlink
realpath
rename
rewind
rmdir
set_file_buffer
stat
symlink
tempnam
tmpfile
touch
umask
unlink
eXTReMe Tracker