subprocess.Popen using relative paths
Question: The [docs](http://docs.python.org/2/library/subprocess.html#popen-constructor)
for Popen mention that you can't specify your executable path relative to the
'change working directory' kwarg.

> If `cwd` is not None, the child’s current directory will be changed to `cwd`
> before it is executed. **Note that this directory is not considered when
> searching the executable, so you can’t specify the program’s path relative
> to`cwd`.**

But python's behaviour on my system seems to directly contradict this claim:

    
    
    wim@SDFA100461C:/tmp$ mkdir a
    wim@SDFA100461C:/tmp$ cp /bin/ls /tmp/a/my_ls
    wim@SDFA100461C:/tmp$ mkdir b
    wim@SDFA100461C:/tmp$ touch /tmp/b/potato
    wim@SDFA100461C:/tmp$ cd /home/wim
    wim@SDFA100461C:~$ python
    Python 2.7.5+ (default, Sep 19 2013, 13:48:49) 
    [GCC 4.8.1] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from subprocess import check_output
    >>> check_output(['../a/my_ls'], cwd='/tmp/b')
    'potato\n'
    >>> check_output(['../a/my_ls'])
    OSError: [Errno 2] No such file or directory
    

Is using relative paths to `cwd` something that is platform dependent and
shouldn't be relied upon? Or is this a documentation bug?

(this question spawns from a comment by glglgl
[here](http://stackoverflow.com/q/21406887/674039#comment32299912_21407005))


Answer: Yes, this is platform dependant.

On POSIX systems, the process is forked and in the child process a
`os.chdir(cwd)` is executed before executing the executable.

On Windows however, the [`CreateProcess()` API
call](http://msdn.microsoft.com/en-
us/library/windows/desktop/ms682425%28v=vs.85%29.aspx) is used and `cwd` is
passed in as the `lpCurrentDirectory` parameter. No directory change takes
place, and the `CreateProcess()` call does _not_ consult that parameter when
looking for the `lpApplicationName` to execute.

To keep your application cross-platform, you should not rely on the current
working directory to be changed when looking up the executable.

