Filipp Gunbin wrote: > In your patch, we don't detach from current (Emacs's) controlling > terminal before doing TIOCSCTTY. Ah, OK. I see also that vfork won't work on Darwin if pty mode is used, since Emacs wants to create a new session and Darwin setsid always fails in a vforked child that has not yet execed. However, your patch introduces another duplicate of the open/TIOCNOTTY/close fallback code, making three duplicates in all. How about if we coalesce these duplicates into a function and then call that function? Also, I think we can call the function from just two places (not three). Furthermore, I think it'd be more robust if Emacs does setsid everywhere (with a fallback to open/TIOCNOTTY/close everywhere TIOCNOTTY is available), not just Darwin. Proposed patch (against master) attached.