Failures when using chdir and proc_open

It seems that the PHP builds provided by Travis are misbehaving when trying to use chdir in combination with proc_open.

When you use chdir with a subdirectory of your repository and then try to execute a binary in that directory via proc_open the execution fails and you get a message like “sh: 1: ./your-script: not found” printed to stdout.

The same script executed with the same cwd via shell_exec works correctly (a test is included demonstrating this).

I’ve tested this across a range of different environments that I have access too and cannot replicate this behavior; as far as I can tell this seems to be travis-specific.

I’ve prepared the simplest test-case I can @

An example failure can be viewed @

Is this any different with some other, “well-behaved builds” of the same PHP versions?

Examining PHP source shows that this is the intended behavior: chdir()/getcwd() etc don’t work with the actual process’ working directory but with a “virtual” one (basically a string in interpreter’s state). While proc_open uses the actual process’ working directory unless overridden.

Yep, I’ve updated the demo repository to include a Dockerfile and steps to to execute these tests against the officially provided PHP docker images - they do not demonstrate the strange behavior I’m seeing in Travis.

Re-checking the API for proc_open I see that I can pass the cwd as an argument so I’ve got a likely path to resolving this for my use-case - however this still looks like an issue with Travis.

1 Like :

--- C:/Users/Sasha/Desktop/phpinfo_travis.txt   Tue Jul 09 13:59:47 2019
+++ C:/Users/Sasha/Desktop/phpinfo_docker.txt   Tue Jul 09 13:59:57 2019 
-Virtual Directory Support => enabled
+Virtual Directory Support => disabled