From: Paul Eggert <eggert@cs.ucla.edu>
To: Jorgen Schaefer <forcer@forcix.cx>
Cc: 17561@debbugs.gnu.org
Subject: bug#17561: Emacs can forget processes
Date: Fri, 23 May 2014 09:28:44 -0700 [thread overview]
Message-ID: <537F773C.8060202@cs.ucla.edu> (raw)
In-Reply-To: <8738g0bigs.fsf@loki.jorgenschaefer.de>
[-- Attachment #1: Type: text/plain, Size: 604 bytes --]
How was Emacs configured and built on your platform? What's your platform?
Can you run the shell command 'strace -p' on an Emacs with the problem,
and trace the system calls near the offending area?
Are you using anything involving SIGUSR1 or SIGUSR2? I see an unlikely
race condition there.
That's part of the problem with this code: it's so racy that it seems
that every time I look at it I find another unlikely race condition.
I'm attaching a patch to emacs-24 for the unlikely races I found in a
quick look at the area, not that I think it'll fix your problem. I
haven't installed this.
[-- Attachment #2: racy.patch --]
[-- Type: text/plain, Size: 2791 bytes --]
=== modified file 'src/nsterm.m'
--- src/nsterm.m 2014-04-04 16:32:24 +0000
+++ src/nsterm.m 2014-05-23 16:13:50 +0000
@@ -4427,7 +4427,7 @@
#ifdef NS_IMPL_GNUSTEP
/* GNUstep steals SIGCHLD for use in NSTask, but we don't use NSTask.
We must re-catch it so subprocess works. */
- catch_child_signal ();
+ catch_child_signal (false);
#endif
return dpyinfo;
}
=== modified file 'src/process.c'
--- src/process.c 2014-05-03 20:13:10 +0000
+++ src/process.c 2014-05-23 16:17:57 +0000
@@ -6254,7 +6254,7 @@
#ifdef NS_IMPL_GNUSTEP
/* NSTask in GNUstep sets its child handler each time it is called.
So we must re-set ours. */
- catch_child_signal();
+ catch_child_signal (true);
#endif
}
@@ -7062,16 +7062,18 @@
/* Arrange to catch SIGCHLD if this hasn't already been arranged.
Invoke this after init_process_emacs, and after glib and/or GNUstep
futz with the SIGCHLD handler, but before Emacs forks any children.
- This function's caller should block SIGCHLD. */
+ futz with the SIGCHLD handler, but before Emacs forks any children.
+ If ALREADY_BLOCKED, this function's caller has already blocked SIGCHLD. */
#ifndef NS_IMPL_GNUSTEP
static
#endif
void
-catch_child_signal (void)
+catch_child_signal (bool already_blocked)
{
struct sigaction action, old_action;
emacs_sigaction_init (&action, deliver_child_signal);
+ if (!already_blocked)
block_child_signal ();
sigaction (SIGCHLD, &action, &old_action);
eassert (! (old_action.sa_flags & SA_SIGINFO));
@@ -7081,6 +7083,7 @@
= (old_action.sa_handler == SIG_DFL || old_action.sa_handler == SIG_IGN
? dummy_handler
: old_action.sa_handler);
+ if (!already_blocked)
unblock_child_signal ();
}
#endif /* subprocesses */
@@ -7107,7 +7110,7 @@
it into lib_child_handler. */
g_source_unref (g_child_watch_source_new (getpid ()));
#endif
- catch_child_signal ();
+ catch_child_signal (false);
}
FD_ZERO (&input_wait_mask);
=== modified file 'src/process.h'
--- src/process.h 2014-01-01 07:43:34 +0000
+++ src/process.h 2014-05-23 16:12:58 +0000
@@ -241,7 +241,7 @@
extern void add_write_fd (int fd, fd_callback func, void *data);
extern void delete_write_fd (int fd);
#ifdef NS_IMPL_GNUSTEP
-extern void catch_child_signal (void);
+extern void catch_child_signal (bool);
#endif
#ifdef WINDOWSNT
=== modified file 'src/sysdep.c'
--- src/sysdep.c 2014-04-16 13:27:28 +0000
+++ src/sysdep.c 2014-05-23 15:58:51 +0000
@@ -1515,6 +1515,12 @@
#ifdef PROFILER_CPU_SUPPORT
sigaddset (&action->sa_mask, SIGPROF);
#endif
+#ifdef SIGUSR1
+ sigaddset (&action->sa_mask, SIGUSR1);
+#endif
+#ifdef SIGUSR2
+ sigaddset (&action->sa_mask, SIGUSR2);
+#endif
#ifdef SIGWINCH
sigaddset (&action->sa_mask, SIGWINCH);
#endif
next prev parent reply other threads:[~2014-05-23 16:28 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-23 15:52 bug#17561: 24.4.50; Emacs can forget processes Jorgen Schaefer
2014-05-23 16:28 ` Paul Eggert [this message]
2014-05-23 16:44 ` bug#17561: " Jorgen Schaefer
2014-05-24 23:01 ` Paul Eggert
2014-05-25 7:57 ` Jorgen Schaefer
2014-05-26 17:08 ` Paul Eggert
2014-05-26 18:49 ` Jorgen Schaefer
2014-05-26 23:58 ` Paul Eggert
2014-05-27 18:27 ` Jorgen Schaefer
2014-05-27 21:42 ` Paul Eggert
2014-05-27 22:16 ` Jorgen Schaefer
2014-05-28 0:47 ` Paul Eggert
2014-05-28 20:53 ` Jorgen Schaefer
2014-05-28 23:00 ` Paul Eggert
2014-05-28 23:35 ` Jorgen Schaefer
2014-05-29 1:22 ` Paul Eggert
2014-05-29 10:08 ` Jorgen Schaefer
2014-05-29 23:15 ` Paul Eggert
2014-05-29 4:17 ` Paul Eggert
2014-05-29 11:39 ` Jorgen Schaefer
2014-05-29 15:09 ` Paul Eggert
2014-05-29 15:22 ` Andreas Schwab
2014-05-29 15:26 ` Paul Eggert
2014-05-29 17:03 ` Jorgen Schaefer
2014-05-29 17:55 ` Andreas Schwab
2014-05-29 18:23 ` Jorgen Schaefer
2014-05-29 19:06 ` Jorgen Schaefer
2014-05-29 20:27 ` Andreas Schwab
2014-05-29 19:15 ` Andreas Schwab
2014-05-30 6:07 ` Paul Eggert
2014-05-30 20:41 ` Jorgen Schaefer
2014-05-30 21:29 ` Paul Eggert
2014-05-27 4:05 ` Paul Eggert
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=537F773C.8060202@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=17561@debbugs.gnu.org \
--cc=forcer@forcix.cx \
/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.