From: Filipp Gunbin <fgunbin@fastmail.fm>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 33050@debbugs.gnu.org, fitzsim@fitzsim.org, alan@idiocy.org
Subject: bug#33050: 27.0.50; [macOS] Problem with process input with process-connection-type nil
Date: Thu, 25 Oct 2018 20:10:06 +0300 [thread overview]
Message-ID: <m2k1m63qc1.fsf@fgunbin.playteam.ru> (raw)
In-Reply-To: <83ftwuq9ii.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 25 Oct 2018 19:24:53 +0300")
On 25/10/2018 19:24 +0300, Eli Zaretskii wrote:
>> From: Filipp Gunbin <fgunbin@fastmail.fm>
>> Cc: Eli Zaretskii <eliz@gnu.org>, 33050@debbugs.gnu.org
>> Date: Thu, 25 Oct 2018 18:51:17 +0300
>>
>> With process-connection-type nil, we call vfork() and then setsid()
>> apparently fails (at least to reset child's controlling terminal).
>>
>> I tried to change the above to just use fork(), and got the correct
>> behavior.
>>
>> If only I knew how to fix this correctly, without reverting to fork()
>> :-) Does anyone have ideas? I'll try to look into this further myself,
>> and will write back.
>
> I'm probably missing something: why are you still trying to find a
> solution, when one was already found? What's wrong with setting
> process-connection-type non-nil in this case, at least for Darwin?
Yes, setting p-c-t to t worked from the start, but it's just a
workaround - there's still problem with p-c-t nil.
I'm currently running with this patch, which is based on Alan's fix in
callproc.c (call_process() had the same problem on Darwin).
Filipp
diff --git a/src/process.c b/src/process.c
index 6cda4f27ac..1f8810927d 100644
--- a/src/process.c
+++ b/src/process.c
@@ -2066,21 +2066,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
int volatile forkerr_volatile = forkerr;
struct Lisp_Process *p_volatile = p;
-#ifdef DARWIN_OS
- /* Darwin doesn't let us run setsid after a vfork, so use fork when
- necessary. Also, reset SIGCHLD handling after a vfork, as
- apparently macOS can mistakenly deliver SIGCHLD to the child. */
- if (pty_flag)
- pid = fork ();
- else
- {
- pid = vfork ();
- if (pid == 0)
- signal (SIGCHLD, SIG_DFL);
- }
-#else
pid = vfork ();
-#endif
current_dir = current_dir_volatile;
lisp_pty_name = lisp_pty_name_volatile;
@@ -2091,15 +2077,35 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
p = p_volatile;
pty_flag = p->pty_flag;
-
if (pid == 0)
#endif /* not WINDOWSNT */
{
+#ifdef DARWIN_OS
+ /* Work around a macOS bug, where SIGCHLD is apparently
+ delivered to a vforked child instead of to its parent. See:
+ https://lists.gnu.org/r/emacs-devel/2017-05/msg00342.html
+ */
+ signal (SIGCHLD, SIG_DFL);
+#endif
+
/* Make the pty be the controlling terminal of the process. */
#ifdef HAVE_PTYS
/* First, disconnect its current controlling terminal.
Do this even if !PTY_FLAG; see Bug#30762. */
+#ifdef DARWIN_OS
+ /* Darwin doesn't let us run setsid after a vfork, so use
+ TIOCNOTTY when necessary. */
+ {
+ int j = emacs_open (DEV_TTY, O_RDWR, 0);
+ if (j >= 0)
+ {
+ ioctl (j, TIOCNOTTY, 0);
+ emacs_close (j);
+ }
+ }
+#else
setsid ();
+#endif
/* Make the pty's terminal the controlling terminal. */
if (pty_flag && forkin >= 0)
{
next prev parent reply other threads:[~2018-10-25 17:10 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-15 19:03 bug#33050: 27.0.50; [macOS] Problem with process input with process-connection-type nil Filipp Gunbin
2018-10-20 10:09 ` Eli Zaretskii
2018-10-22 15:35 ` Filipp Gunbin
2018-10-23 1:53 ` Thomas Fitzsimmons
2018-10-23 22:41 ` Filipp Gunbin
2018-10-24 1:55 ` Thomas Fitzsimmons
2018-10-24 13:13 ` Filipp Gunbin
2018-10-24 14:05 ` Filipp Gunbin
2018-10-24 16:20 ` Thomas Fitzsimmons
2018-10-24 19:33 ` Filipp Gunbin
2018-10-24 19:46 ` Filipp Gunbin
2018-10-24 22:07 ` Thomas Fitzsimmons
2018-10-25 15:51 ` Filipp Gunbin
2018-10-25 16:24 ` Eli Zaretskii
2018-10-25 17:10 ` Filipp Gunbin [this message]
2018-10-25 17:29 ` Eli Zaretskii
2018-10-25 18:10 ` Filipp Gunbin
2018-10-25 18:20 ` Eli Zaretskii
2018-10-25 19:36 ` Filipp Gunbin
2018-10-25 19:40 ` Eli Zaretskii
2018-10-25 20:47 ` Filipp Gunbin
2018-10-26 6:29 ` Eli Zaretskii
2018-10-26 1:41 ` Thomas Fitzsimmons
2018-10-26 7:00 ` Eli Zaretskii
2018-10-26 15:41 ` Thomas Fitzsimmons
2018-10-26 17:20 ` Eli Zaretskii
2018-10-27 10:20 ` Eli Zaretskii
2018-10-27 13:42 ` Thomas Fitzsimmons
2018-10-27 14:53 ` Eli Zaretskii
2018-10-27 16:53 ` Thomas Fitzsimmons
2018-10-27 18:49 ` Eli Zaretskii
2018-10-26 23:12 ` Filipp Gunbin
2018-10-27 2:09 ` Thomas Fitzsimmons
2018-10-27 14:52 ` Filipp Gunbin
2018-10-30 0:49 ` Thomas Fitzsimmons
2018-10-30 19:11 ` Filipp Gunbin
2018-11-28 23:09 ` Filipp Gunbin
2018-11-29 7:21 ` Eli Zaretskii
2018-11-29 8:46 ` Filipp Gunbin
2018-11-29 9:19 ` Eli Zaretskii
2018-11-29 9:51 ` Filipp Gunbin
2018-11-29 10:41 ` Eli Zaretskii
2018-11-29 14:09 ` Filipp Gunbin
2018-12-03 14:17 ` Thomas Fitzsimmons
2018-12-04 12:37 ` Filipp Gunbin
2018-12-22 15:05 ` Thomas Fitzsimmons
2018-10-27 6:59 ` Eli Zaretskii
2018-10-27 14:37 ` Filipp Gunbin
2018-10-27 20:28 ` Charles A. Roelli
2018-10-28 16:00 ` Eli Zaretskii
2018-10-28 19:53 ` Charles A. Roelli
2018-10-25 16:41 ` Filipp Gunbin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2k1m63qc1.fsf@fgunbin.playteam.ru \
--to=fgunbin@fastmail.fm \
--cc=33050@debbugs.gnu.org \
--cc=alan@idiocy.org \
--cc=eliz@gnu.org \
--cc=fitzsim@fitzsim.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.