From: yolcoyama at gmail dot com Operating system: Linux ubo 2.6.28-11-generic PHP version: 5.2.9 PHP Bug Type: Filesystem function related Bug description: Wrong error number returned by system, passthru functions
Description: ------------ Trying to install crontab with PHP cli, system (and passthru) function returned error-code of "1" with output "no crontab for USER" (USER should be replaced with real system user to whom crontab should be installed). the code is: $ php -r '$c="crontab -u USER -l";system($c,$status); printf("%s (%d)\n",$c,$status);' the output is: no crontab for USER crontab -u USER -l (1) Since no crontab is been installed for the USER, the output was expected, but I don't think error code should be 1 for this. For comparison, python and c++ both returns 256 of error code for this error ("no crontab for USER be installed"). According to an error code definition of unix system (in ubuntu, /usr/include/asm-generic/errno-base.h and errno.h), 1 be translated as "permission denied". Followings are comparison code and result for other languages. They returned error number 256 but PHP. * c++ #include <iostream> #include <cstdlib> using namespace std; int main(int argc,char *argv[]){ string cmnd("crontab -u USER -l"); int errcode=system(cmnd.data()); printf( "%s (%d)\n", cmnd.data(), errcode ); return 0; } r...@server2:~/diary# ./a.out no crontab for USER crontab -u USER -l (256) * python r...@server2:~/diary# python -c 'import os; c="crontab -u USER -l"; print "%s (%d)" % (c, os.system(c))' no crontab for USER crontab -u USER -l (256) * php r...@server2:~/diary# php -r '$c="crontab -u USER -l";system($c,$status); printf("%s (%d)\n",$c,$status);' no crontab for USER crontab -u USER -l (1) * error number refference r...@server2:~/diary# awk '/[\x20\t]+1[\x20\t]+/' /usr/include/asm-generic/errno-base.h #define EPERM 1 // Operation not permitted Reproduce code: --------------- # make sure there's NO crontab installed for USER. $ php -r '$c="crontab -u USER -l";system($c,$status); printf("%s (%d)\n",$c,$status);' Expected result: ---------------- Output: no crontab for USER crontab -u USER -l (256) Actual result: -------------- Output: no crontab for USER crontab -u USER -l (1) -- Edit bug report at http://bugs.php.net/?id=48576&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48576&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48576&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48576&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=48576&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48576&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=48576&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=48576&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=48576&r=needscript Try newer version: http://bugs.php.net/fix.php?id=48576&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=48576&r=support Expected behavior: http://bugs.php.net/fix.php?id=48576&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=48576&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=48576&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=48576&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48576&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=48576&r=dst IIS Stability: http://bugs.php.net/fix.php?id=48576&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=48576&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=48576&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=48576&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=48576&r=mysqlcfg