Subject: bug#8705: 23.3; Emacs occasionally crashes (segfault) just after starting it

From: Daniel Colascione <[email-masked]>
Date: Fri, 06 Jul 2012 15:51:58 -0700

On 7/6/2012 1:32 PM, Troels Nielsen wrote:
> It appears this is due to Fcall_process not restoring environ before
> after UNBLOCK_INPUT. This is too late in your case.
> 
> The patch below against trunk, ought to fix it with minimal
> intervention. But I think a better fix would be to abandon the use of
> vfork and just use fork (which should be almost as fast), as the work
> in the child process after vfork is undefined behavior as far as I can
> understand.

Better yet, we can use posix_spawn, falling back to gnulib's
implementation of posix_spawn in terms of fork or vfork. Unfortunately,
posix_spawn has no way of telling the child to setsid, so the best we
could do would be setpgrp. I have patches to use posix_spawn in the
call_process case, but not the async case.

I'm not entirely sure how much of a difference avoiding setsid makes. In
the meantime, retaining support for vfork would be nice, because on some
platforms, like Cygwin, fork is still very slow.