ID:               48576
 Updated by:       j...@php.net
 Reported By:      yolcoyama at gmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Filesystem function related
 Operating System: Linux ubo 2.6.28-11-generic
 PHP Version:      5.2.9
 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.




Previous Comments:
------------------------------------------------------------------------

[2009-06-23 19:42:57] sjoerd-php at linuxonly dot nl

Thank you for your bug report.

On my system, crontab returns 1, as shown by these commands:
crontab -l -u USER; echo $?

This thus means that PHP returns the correct exit status. Instead, the
system() system call behaves strangely. You can show this by compiling a
program which returns 1 in its main loop and call that program using
system(). It will return 256 as return status. Python documents this
somewhat better than the C++ system call:

[It will] return a tuple containing its pid and exit status indication:
a 16-bit number, whose low byte is the signal number that killed the
process, and whose high byte is the exit status (if the signal number is
zero); the high bit of the low byte is set if a core file was produced.

------------------------------------------------------------------------

[2009-06-17 06:35:23] yolcoyama at gmail dot com

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 this bug report at http://bugs.php.net/?id=48576&edit=1

Reply via email to