Improve fork() on Windows. #252

Merged
merged 1 commit into from May 9, 2014

Conversation

Projects
None yet
2 participants
@living180
Contributor

living180 commented May 8, 2014

The Windows implementation of fork(), _fork_win32(), had some code to try to allow commands like gitk to be executed. However, this code did not work for multiple reasons. The main issue is that on Windows, gitk is actually provided by a batch file named gitk.cmd. If the first element in the args list passed to subprocess.Popen() is simply "gitk", the file won't be found and the command will fail. This could be solved by passing shell=True to Popen(), but that is not ideal. The fix provided here is to implement the same path searching algorithm that the Windows shell uses to locate an executable, taking into account the PATHEXT environment variable, and to use the result of that search as the first element of the args list for subprocess.Popen().

[core] improve fork() on Windows
The Windows implementation of fork(), _fork_win32(), had some code to
try to allow commands like gitk to be executed.  However, this code did
not work for multiple reasons.  The main issue is that on Windows, gitk
is actually provided by a batch file named gitk.cmd.  If the first
element in the args list passed to subprocess.Popen() is simply "gitk",
the file won't be found and the command will fail.  This could be solved
by passing shell=True to Popen(), but that is not ideal.  The fix
provided here is to implement the same path searching algorithm that the
Windows shell uses to locate an executable, taking into account the
PATHEXT environment variable, and to use the result of that search as
the first element of the args list for subprocess.Popen().

Signed-off-by: Daniel Harding <dharding@living180.net>

davvid added a commit that referenced this pull request May 9, 2014

Merge pull request #252 from living180/improve_fork_on_windows
Improve fork() on Windows.

Signed-off-by: David Aguilar <davvid@gmail.com>

@davvid davvid merged commit e6b5559 into git-cola:master May 9, 2014

@living180 living180 deleted the living180:improve_fork_on_windows branch May 9, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment