2

The proc_open() documentation states that it's possible to use other file descriptors than the standard ones:

The file descriptor numbers are not limited to 0, 1 and 2 - you may specify any valid file descriptor number and it will be passed to the child process.

But how do you actually go about doing this?

What do you need to do on the parent and child process to for example use an extra input and output pipe with a proc_open call?

Edit:

A related question - If the launched process was also a PHP function, you can access an arbitrary fd in PHP with the stream wrapper php://fd/3 (replace 3 with the fd number), but this feature is only available in PHP 5.3.6+. Is there any way of accessing an arbitrary fd in PHP 5.2?

John Carter
  • 53,924
  • 26
  • 111
  • 144
  • Did you read the comments at the corresponding manual page? – KingCrunch Jul 25 '11 at 12:52
  • @KingCrunch which page? Note that I'm talking about a PHP function here. – John Carter Jul 25 '11 at 12:57
  • You linked it yourself ... http://php.net/manual/en/function.proc-open.php See _your_ question above. – KingCrunch Jul 25 '11 at 13:03
  • @KingCrunch Ah, sorry I thought you were telling me to look at a `man` page. There is one example ( http://www.php.net/manual/en/function.proc-open.php#83635 ). Is it really that simple? I didn't think I could pick an arbitrary fd number. – John Carter Jul 25 '11 at 13:27

0 Answers0