How to start a background process in PHP and read / write it stdout / stdin?

As an extension of the question " php execute background process ":

Suppose I wanted to keep a process running during a PHP session as an interactive shell bash. How to set the stdout / stdin redirection so that PHP can read / write to the process?

UPDATE: the key should be to start this process and save it in the background so that subsequent requests can access its stdout / stdin threads.

+3
source share
3 answers
+2

Linux, proc /proc. , Ubuntu Server stdio /proc/ <pid> /fd/[012]. 0 - stdin, 1 - stdout, 2 - stderr. , , , /dev/null, . pid (a la http://nsaunders.wordpress.com/2007/01/12/running-a-background-process-in-php/), stdin/stdout Linux.

+1

PHP , mulitple shell_exec

shell_exec will return the full output, which you can then respond to the user.

0
source

Source: https://habr.com/ru/post/1754681/


All Articles