[ Pobierz całość w formacie PDF ]
.See also pcntl_waitpid() and pcntl_wifexited().pcntl_wifexited (PHP 4 >= 4.1.0)ReturnsTRUEif status code represents a successful exitint pcntl_wifexited ( int status) \linebreakReturnsTRUEif the child status code represents a successful exit.The parameterstatusis the status parameter supplied to a successfull call to pcntl_waitpid().See also pcntl_waitpid() and pcntl_wexitstatus().pcntl_wifsignaled (PHP 4 >= 4.1.0)ReturnsTRUEif status code represents a termination due to a signalint pcntl_wifsignaled ( int status) \linebreakReturnsTRUEif the child process exited because of a signal which was not caught.The parameterstatusis the status parameter supplied to a successfull call to pcntl_waitpid().See also pcntl_waitpid() and pcntl_signal().pcntl_wifstopped (PHP 4 >= 4.1.0)ReturnsTRUEif child process is currently stoppedint pcntl_wifstopped ( int status) \linebreakReturnsTRUEif the child process which caused the return is currently stopped; this is only possibleif the call to pcntl_waitpid() was done using the optionWUNTRACED.The parameterstatusis the status parameter supplied to a successfull call to pcntl_waitpid().See also pcntl_waitpid().pcntl_wstopsig (PHP 4 >= 4.1.0)Returns the signal which caused the child to stopint pcntl_wstopsig ( int status) \linebreak1376PCNTLReturns the number of the signal which caused the child to stop.This function is only useful ifpcntl_wifstopped() returnedTRUE.The parameterstatusis the status parameter supplied to a successfull call to pcntl_waitpid().See also pcntl_waitpid() and pcntl_wifstopped().pcntl_wtermsig (PHP 4 >= 4.1.0)Returns the signal which caused the child to terminateint pcntl_wtermsig ( int status) \linebreakReturns the number of the signal that caused the child process to terminate.This function is onlyuseful if pcntl_wifsignaled() returnedTRUE.The parameterstatusis the status parameter supplied to a successfull call to pcntl_waitpid().See also pcntl_waitpid(), pcntl_signal() and pcntl_wifsignaled().1377LXXXII.Program Execution functionsWprowadzenieThose functions provides means to executes commands on the system itself, and means secure suchcommands.WymaganiaTe funkcje są częścią modułu podstawowego, dlatego są zawsze dostępne.InstalacjaBy używać tych funkcji, nie trzeba niczego instalować.Są one częścią jądra PHP.Konfiguracja startowaTo rozszerzenie nie definiuje żadnych dyrektyw konfiguracyjnych.Typy zasobówTo rozszerzenie nie definiuje żadnych rodzajów zasobów.Predefiniowane stałeTo rozszerzenie nie definiuje żadnych stałych.Zobacz równieżThose functions are also closely related to the backtick operator.1378Program Executionescapeshellarg (PHP 4 >= 4.3)escape a string to be used as a shell argumentstring escapeshellarg ( string arg) \linebreakescapeshellarg() adds single quotes around a string and quotes/escapes any existing single quotesallowing you to pass a string directly to a shell function and having it be treated as a single safeargument.This function should be used to escape individual arguments to shell functions comingfrom user input.The shell functions include exec(), system() and the backtick operator.A standarduse would be:system("ls ".escapeshellarg($dir));See also exec(), popen(), system(), and the backtick operator.escapeshellcmd (PHP 3, PHP 4 )escape shell metacharactersstring escapeshellcmd ( string command) \linebreakescapeshellcmd() escapes any characters in a string that might be used to trick a shell command intoexecuting arbitrary commands.This function should be used to make sure that any data coming fromuser input is escaped before this data is passed to the exec() or system() functions, or to the backtickoperator.A standard use would be:$e = escapeshellcmd($userinput);system("echo $e"); // here we don t care if $e has spaces$f = escapeshellcmd($filename);system("touch \"/tmp/$f\"; ls -l \"/tmp/$f\""); // and here we do, so we use quotesSee also escapeshellarg(), exec(), popen(), system(), and the backtick operator.exec (PHP 3, PHP 4 )Execute an external programstring exec ( string command [, array output [, int return_var]]) \linebreak1379Program Executionexec() executes the givencommand, however it does not output anything.It simply returns the lastline from the result of the command.If you need to execute a command and have all the data fromthe command passed directly back without any interference, use the passthru() function.If thearray argument is present, then the specified array will be filled with every line of outputfrom the command.Note that if the array already contains some elements, exec() will append to theend of the array.If you do not want the function to append elements, call unset() on the array beforepassing it to exec().If thereturn_varargument is present along with thearray argument, then the return status ofthe executed command will be written to this variable.OstrzeżenieIf you are going to allow data coming from user input to be passed to thisfunction, then you should be using escapeshellarg() or escapeshellcmd() tomake sure that users cannot trick the system into executing arbitrarycommands.Notatka: If you start a program using this function and want to leave it running in thebackground, you have to make sure that the output of that program is redirected to a file or someother output stream or else PHP will hang until the execution of the program ends.See also system(), passthru(), popen(), escapeshellcmd(), and the backtick operator.passthru (PHP 3, PHP 4 )Execute an external program and display raw outputvoid passthru ( string command [, int return_var]) \linebreakThe passthru() function is similar to the exec() function in that it executes acommand.If thereturn_varargument is present, the return status of the Unix command will be placed here.Thisfunction should be used in place of exec() or system() when the output from the Unix command isbinary data which needs to be passed directly back to the browser.A common use for this is toexecute something like the pbmplus utilities that can output an image stream directly.By setting theContent-type to image/gif and then calling a pbmplus program to output a gif, you can create PHPscripts that output images directly.OstrzeżenieIf you are going to allow data coming from user input to be passed to thisfunction, then you should be using escapeshellarg() or escapeshellcmd() tomake sure that users cannot trick the system into executing arbitrarycommands.Notatka: If you start a program using this function and want to leave it running in thebackground, you have to make sure that the output of that program is redirected to a file or someother output stream or else PHP will hang until the execution of the program ends.1380Program ExecutionSee also exec(), system(), popen(), escapeshellcmd(), and the backtick operator.proc_close (PHP 4 CVS only)Close a process opened by proc_open and return the exit code of that process.int proc_close ( resource process) \linebreakproc_close() is similar to pclose() except that it only works on processes opened by proc_open().proc_close() waits for the process to terminate, and returns it s exit code.If you have open pipes tothat process, you should fclose() them prior to calling this function in order to avoid a deadlock - thechild process may not be able to exit while the pipes are open.proc_open (PHP 4 CVS only)Execute a command and open file pointers for input/outputresource proc_open ( string cmd, array descriptorspec, array pipes) \linebreakproc_open() is similar to popen() but provides a much greater degree of control over the programexecution.cmdis the command to be executed by the shell.descriptorspecis an indexed arraywhere the key represents the descriptor number and the value represents how PHP will pass thatdescriptor to the child process
[ Pobierz całość w formacie PDF ]