Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Detach Git Bash
Browse files Browse the repository at this point in the history
When called from the Windows Explorer, we must not wait for the
stdout/stderr of Git Bash.

A recent change made for FarManager makes Git Cheetah capture
stderr/stdout even when we are not interested in it, to avoid cluttering
FarManager's precious console. Due to this workaround, Git Bash makes the
Explorer -- Git Cheetah's primary intended consumer -- hang.

Since Git Bash does not output anything to the calling console, let's just
force the detached mode by avoiding the FarManager workaround *just* for
Git Bash.

Thanks to John Stevenson for catching a bug in an earlier version of this
commit.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
dscho committed Mar 24, 2014
1 parent da97444 commit e7af798
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion common/cheetahmenu.c
Expand Up @@ -149,7 +149,7 @@ static int menu_bash(struct git_data *this_, UINT id)
return 0;
}

exec_program_v(wd, NULL, NULL, NORMALMODE, argv);
exec_program_v(wd, NULL, NULL, DETACHMODE, argv);

if (argv_free)
argv_free(argv_data);
Expand Down
9 changes: 5 additions & 4 deletions common/exec.c
Expand Up @@ -54,7 +54,7 @@ int exec_program_v(const char *working_directory,
return -1;
}

if (!output || !error_output)
if ((!output || !error_output) && !(DETACHMODE & flags))
devnull = open("/dev/null", O_WRONLY);

s1 = dup(1);
Expand All @@ -65,7 +65,7 @@ int exec_program_v(const char *working_directory,
dup2(fdout[1], 1);

flags |= WAITMODE;
} else {
} else if (devnull >= 0) {
dup2(devnull, 1);
}

Expand All @@ -79,10 +79,11 @@ int exec_program_v(const char *working_directory,
dup2(fderr[1], 2);

flags |= WAITMODE;
} else {
} else if (devnull >= 0) {
dup2(devnull, 2);
}
close(devnull);
if (devnull >= 0)
close(devnull);

pid = fork_process(argv[0], argv, working_directory);

Expand Down
1 change: 1 addition & 0 deletions common/exec.h
Expand Up @@ -2,6 +2,7 @@
#define NORMALMODE (0)
#define HIDDENMODE (1 << 0) /* hide any windows, opened by execution */
#define WAITMODE (1 << 1) /* wait for execution to complete */
#define DETACHMODE (1 << 2) /* do *not* wait for execution to complete */
#define QUIETMODE (1 << 7) /* don't report any errors to user */

enum {
Expand Down

0 comments on commit e7af798

Please sign in to comment.