0

I'm currently planning to use Symfony's ProcessBuilder, which allows to set some environment variable which will be passed onto a proc_open call.

I need for a certain command to change the TMPDIR, and to restore it afterwards, so I was wondering if, when the modified env (and thus modified value for the $TMPDIR env variable) would be restored after the call, or do I need to restore it myself ? And will this value be indeed changed if need be for a particular command (which is ghostscript in my case) ?

Thanks

Talus
  • 754
  • 7
  • 18
  • 1
    Assuming you are using `putenv` to change the environment variable, it will revert to the standard setting when the request is complete. You can use a combination of `getenv` to copy the old value and `putenv` to reset it yourself for the duration of the request in case something else in your script tries to use it. – kainaw Aug 18 '15 at 15:34
  • I'm refering to the `$env` argument of the `proc_open` function, but I guess `putenv` could also do the trick then... – Talus Aug 18 '15 at 15:43
  • 1
    Sorry. I wasn't reading the whole question. The env in `proc_open` is not PHP's environment. It will last as long as you keep the I/O pointer open, but only for the command used to open the pointer. – kainaw Aug 18 '15 at 16:23
  • After some tests, that's what it is, so it basically does what I need it to do. Problem solved, thanks ! – Talus Aug 18 '15 at 16:24

1 Answers1

0

After some tests, it seems that the $env parameter in the proc_open function is really to modify the environment only for the duration of the run process. So it basically covers my question. :}

Talus
  • 754
  • 7
  • 18