note 63729 added to function.exec

From: Date: Wed, 29 Mar 2006 12:12:17 +0000
Subject: note 63729 added to function.exec
Groups: php.notes 
Request: Send a blank email to php-notes+get-106940@lists.php.net to get a copy of this message
I've done a C program to act as a "timeout controller" process, by forking itself and executing some other command received as parameter. Then, in PHP I have a function that calls commands this way: <?php ... $command = "tout_controller <tout> <command_name> <command_args>" exec($command,$status); echo "Exit status code of command is $status"; ... ?> I've noticed that exit status code returned from a C process is a "special" integer. I wanted "command" exit status code to be returned to controller, and then controller to exit with same status code (to get this status from PHP). Exit status was always 0 !!! To solve this, i've found a C macro to use inside tout_controller: <C code snippet> .. waitpid(pid,&status,0); // wait for process that execs COMMAND .. //exit(status); // that doesn't work exit(WEXITSTATUS(ret)); // that's ok .. </C code snippet> It isn't exactly a PHP note, but may be useful to help some desperated programmer's ;) ---- Server IP: 130.206.1.5 Probable Submitter: 213.97.146.237 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.exec.php Edit -- http://master.php.net/note/edit/63729 Del: integrated -- http://master.php.net/note/delete/63729/integrated Del: useless -- http://master.php.net/note/delete/63729/useless Del: bad code -- http://master.php.net/note/delete/63729/bad+code Del: spam -- http://master.php.net/note/delete/63729/spam Del: non-english -- http://master.php.net/note/delete/63729/non-english Del: in docs -- http://master.php.net/note/delete/63729/in+docs Del: other reasons-- http://master.php.net/note/delete/63729 Reject -- http://master.php.net/note/reject/63729 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#106940) next »