PHP/lib/proc: Difference between revisions
Created page with "{{fmt/title|PHP local process management}} ==About== This is probably the most basic of the local process-management libraries; I'm not sure if that's a fair description becau..." |
No edit summary |
||
| Line 1: | Line 1: | ||
{{fmt/title|PHP local process management}} | {{fmt/title|PHP local process management}} | ||
==About== | ==About== | ||
This is probably the most basic of the local process-management libraries; I'm not sure if that's a fair description because I haven't tried any of the other possibly-overlapping libraries yet (see [https://www.php.net/manual/en/refs.fileprocess.process.php Process Control Extensions]). | This is probably the most basic of the local process-management libraries<ref name=popen />; I'm not sure if that's a fair description because I haven't tried any of the other possibly-overlapping libraries yet (see [https://www.php.net/manual/en/refs.fileprocess.process.php Process Control Extensions]). | ||
==Model== | ==Model== | ||
* A process is opened by executing a command via <code>{{l/pfx|PHP/fx/|proc_open}}()</code><sup>[https://www.php.net/manual/en/function.proc-open.php php]</sup>. | * A process is opened by executing a command via <code>{{l/pfx|PHP/fx/|proc_open}}()</code><sup>[https://www.php.net/manual/en/function.proc-open.php php]</sup>. | ||
| Line 14: | Line 14: | ||
==Links== | ==Links== | ||
* php.net: [https://www.php.net/manual/en/book.exec.php System program execution] | * php.net: [https://www.php.net/manual/en/book.exec.php System program execution] | ||
==Footnote== | |||
<references> | |||
<ref name=popen>I'm not counting <code>[https://www.php.net/manual/en/function.popen.php popen]()</code> because that doesn't allow dialogue with the process; it just runs it and hands you a pipe-stream for either the process's output ''or'' your input to it.</ref> | |||
</references> | |||
Latest revision as of 00:28, 27 March 2026
About
This is probably the most basic of the local process-management libraries<ref name=popen />; 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
Template:L/pfx()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
Template:L/pfx()php. - Its priority is modifiable via
Template:L/pfx()php. - It may be terminated via
Template:L/pfx()php (which waits politely for the process to be done) orTemplate:L/pfx()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 Template:L/pfx() 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 "Template:L/cmd" or "Template:L/cmd" 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
Footnote
<references>
<ref name=popen>I'm not counting popen() because that doesn't allow dialogue with the process; it just runs it and hands you a pipe-stream for either the process's output or your input to it.</ref>
</references>
