note 38044 added to function.system

From: Date: Fri, 05 Dec 2003 20:50:44 +0000
Subject: note 38044 added to function.system
Groups: php.notes 
Request: Send a blank email to php-notes+get-61464@lists.php.net to get a copy of this message
The documentation says the second argument, if present, returns the "return status code" of the executed command. It also claims the PHP system() function is "just like the C version" which might lead one to think that the "return status code" is the same returned status code that the C system(3) command returns. It is not. For executed commands that exit normally (no signal was caught), the returned value in the second argument is the 8-bit integer value passed to the exit(3) command. For programs that exit with a signal, I don't know what PHP will return, but it's probably useless or wrong data. The C system(3) function returns an integer status code, which contains as one of its 8-bit bytes, the above 8-bit exit() value. (On BSD systems, it's actually the second byte, that is, is obtained by this expression: status >> 8. See /usr/include/sys/wait.h.) Anyone who has done compiled language programming on Unix systems (e.g. C, C++) may get bitten by this misleading documentation. ---- Manual Page -- http://www.php.net/manual/en/function.system.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+38044 Delete -- http://master.php.net/manage/user-notes.php?action=delete+38044&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+38044&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#61464) next »