PHP/lib/proc
|
PHP local process management
|
About
This is probably the most basic of the local process-management libraries[1]; I'm not sure if that's a fair description because I haven't tried any of the other possibly-overlapping libraries yet (see Process Control Extensions).
Model
- A process is opened by executing a command via
proc_open()php. - While it is open:
- it may send output through
stdout(information) orstderr(error messages) - it may receive input via
stdin - Its status may be obtained via
proc_get_status()php. - Its priority is modifiable via
proc_nice()php. - It may be terminated via
proc_close()php (which waits politely for the process to be done) orproc_terminate()php (which forces the issue).
- it may send output through
Unlike SSH2, this library does not have a concept of opening a process without first executing a command; the command is the process. Each command opened with proc_open() is like a separate terminal session. In order to maintain any kind of persistent session-state across multiple commands, you have to first run some kind of wrapper-command like "bash" or "script" and then transmit additional commands to that wrapper-command via stdin. (The meaning of those additional commands will, of course, depend entirely on how the wrapper-command interprets them.)
Links
- php.net: System program execution