On a new PHP session on a linux web server, I want to start a process (specifically ghostscript) running in the background in console input mode and then repeatedly write new data to its input. This data write needs to occur every time new user data arrives via ajax. The user data is interpreted by the PHP script into postscript commands for ghostscript and then needs to be sent to gs. The gs output will be to a named file. The reason for doing this is that I need speed and want to avoid the overhead of starting gs on each new input from the user. (Once gs is running and waiting for input it takes about 40ms to process my data, but restarting gs and processing the data is taking around 250ms.) Although I can get gs to run in the background and accept input from the shell, I am having difficulty getting it to do this from a PHP script. I've been through all the variations of exec, shell_exec, popen, system, coproc, etc. that I can think of and I seem to be missing something fundamental. Thanks for any insights.