Skip to content

Commit

Permalink
Revert "Double fork to avoid Vim hanging when using zsh"
Browse files Browse the repository at this point in the history
This reverts commit 453876f.

This is not the right/complete solution.
  • Loading branch information
Nikola Knezevic authored and b4winckler committed Aug 29, 2010
1 parent 453876f commit daa43ff
Showing 1 changed file with 6 additions and 31 deletions.
37 changes: 6 additions & 31 deletions src/os_macosx.m
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
void
macosx_fork()
{
pid_t pid, nextpid;
pid_t pid;
int i;

/*
Expand Down Expand Up @@ -251,36 +251,11 @@
/* Make sure we survive our shell */
setsid();

close(0);
close(1);
close(2);

/* Now, do fork() again. This way, the child becomes a child of the
* init process. It is the responsibility of init process to do
* cleanup when child dies. This way, MacVim will never be able to
* acquire the controlling terminal.
* This fixes a bug where Vim would hang forever when using zsh.
*/
nextpid = fork();
switch(nextpid) {
case -1:
#ifndef NDEBUG
/* This probably won't work, since stderr is closed */
fprintf(stderr, "vim: Mac OS X workaround for fork() failed!");
#endif
_exit(255);
case 0:
/* Grandchild */

/* Restarts the vim process, will not return. */
execvp(argv[0], newargv);

/* If we come here, exec has failed. bail. */
_exit(255);
default:
/* Child, again */
_exit(0);
}
/* Restarts the vim process, will not return. */
execvp(argv[0], newargv);

/* If we come here, exec has failed. bail. */
_exit(255);
default:
/* Parent */
_exit(0);
Expand Down

0 comments on commit daa43ff

Please sign in to comment.