From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#15561: periodic timer stops running Date: Thu, 27 Feb 2014 12:43:56 -0800 Organization: UCLA Computer Science Department Message-ID: <530FA38C.5000303@cs.ucla.edu> References: <87wqggoa8r.fsf@micropit.couberia.selfip.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------000307030603030600000309" X-Trace: ger.gmane.org 1393533912 5211 80.91.229.3 (27 Feb 2014 20:45:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 27 Feb 2014 20:45:12 +0000 (UTC) To: Peter =?UTF-8?Q?M=C3=BCnster?= , 15561@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Feb 27 21:45:20 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WJ7pW-0003oj-L6 for geb-bug-gnu-emacs@m.gmane.org; Thu, 27 Feb 2014 21:45:18 +0100 Original-Received: from localhost ([::1]:47896 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJ7pW-00080H-3Q for geb-bug-gnu-emacs@m.gmane.org; Thu, 27 Feb 2014 15:45:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47915) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJ7pM-0007rp-NF for bug-gnu-emacs@gnu.org; Thu, 27 Feb 2014 15:45:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WJ7pG-00076t-Pu for bug-gnu-emacs@gnu.org; Thu, 27 Feb 2014 15:45:08 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41915) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJ7pG-00076e-Kz for bug-gnu-emacs@gnu.org; Thu, 27 Feb 2014 15:45:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WJ7pG-0003HU-B8 for bug-gnu-emacs@gnu.org; Thu, 27 Feb 2014 15:45:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 27 Feb 2014 20:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15561 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 15561-submit@debbugs.gnu.org id=B15561.139353384212494 (code B ref 15561); Thu, 27 Feb 2014 20:45:02 +0000 Original-Received: (at 15561) by debbugs.gnu.org; 27 Feb 2014 20:44:02 +0000 Original-Received: from localhost ([127.0.0.1]:43097 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WJ7oH-0003FB-4A for submit@debbugs.gnu.org; Thu, 27 Feb 2014 15:44:02 -0500 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:60109) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WJ7oE-0003F0-5Z for 15561@debbugs.gnu.org; Thu, 27 Feb 2014 15:43:59 -0500 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id BC49E39E8013; Thu, 27 Feb 2014 12:43:57 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GlS9qXDeDI9r; Thu, 27 Feb 2014 12:43:56 -0800 (PST) Original-Received: from penguin.cs.ucla.edu (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id D27B639E8008; Thu, 27 Feb 2014 12:43:56 -0800 (PST) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 In-Reply-To: <87wqggoa8r.fsf@micropit.couberia.selfip.net> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:86328 Archived-At: This is a multi-part message in MIME format. --------------000307030603030600000309 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Following up to: http://lists.gnu.org/archive/html/emacs-devel/2014-02/msg00593.html Does the attached patch fix things for you? It's relative to Emacs trunk bzr 116586. --------------000307030603030600000309 Content-Type: text/x-patch; name="timer.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="timer.diff" === modified file 'src/atimer.c' --- src/atimer.c 2014-01-01 07:43:34 +0000 +++ src/atimer.c 2014-02-27 20:15:21 +0000 @@ -50,22 +50,17 @@ /* Block/unblock SIGALRM. */ static void -sigmask_atimers (int how) +block_atimers (sigset_t *oldset) { sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGALRM); - pthread_sigmask (how, &blocked, 0); -} -static void -block_atimers (void) -{ - sigmask_atimers (SIG_BLOCK); -} -static void -unblock_atimers (void) -{ - sigmask_atimers (SIG_UNBLOCK); + pthread_sigmask (SIG_BLOCK, &blocked, oldset); +} +static void +unblock_atimers (sigset_t const *oldset) +{ + pthread_sigmask (SIG_SETMASK, oldset, 0); } /* Function prototypes. */ @@ -98,6 +93,7 @@ atimer_callback fn, void *client_data) { struct atimer *t; + sigset_t oldset; /* Round TIME up to the next full second if we don't have itimers. */ @@ -122,7 +118,7 @@ t->fn = fn; t->client_data = client_data; - block_atimers (); + block_atimers (&oldset); /* Compute the timer's expiration time. */ switch (type) @@ -143,7 +139,7 @@ /* Insert the timer in the list of active atimers. */ schedule_atimer (t); - unblock_atimers (); + unblock_atimers (&oldset); /* Arrange for a SIGALRM at the time the next atimer is ripe. */ set_alarm (); @@ -158,8 +154,9 @@ cancel_atimer (struct atimer *timer) { int i; + sigset_t oldset; - block_atimers (); + block_atimers (&oldset); for (i = 0; i < 2; ++i) { @@ -186,7 +183,7 @@ } } - unblock_atimers (); + unblock_atimers (&oldset); } @@ -217,7 +214,8 @@ void stop_other_atimers (struct atimer *t) { - block_atimers (); + sigset_t oldset; + block_atimers (&oldset); if (t) { @@ -242,7 +240,7 @@ stopped_atimers = append_atimer_lists (atimers, stopped_atimers); atimers = t; - unblock_atimers (); + unblock_atimers (&oldset); } @@ -256,8 +254,9 @@ { struct atimer *t = atimers; struct atimer *next; + sigset_t oldset; - block_atimers (); + block_atimers (&oldset); atimers = stopped_atimers; stopped_atimers = NULL; @@ -268,7 +267,7 @@ t = next; } - unblock_atimers (); + unblock_atimers (&oldset); } } @@ -381,9 +380,10 @@ { if (atimers) { - block_atimers (); + sigset_t oldset; + block_atimers (&oldset); run_timers (); - unblock_atimers (); + unblock_atimers (&oldset); } } === modified file 'src/callproc.c' --- src/callproc.c 2014-01-30 17:22:30 +0000 +++ src/callproc.c 2014-02-27 20:18:18 +0000 @@ -108,20 +108,20 @@ /* Block SIGCHLD. */ void -block_child_signal (void) +block_child_signal (sigset_t *oldset) { sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); - pthread_sigmask (SIG_BLOCK, &blocked, 0); + pthread_sigmask (SIG_BLOCK, &blocked, oldset); } /* Unblock SIGCHLD. */ void -unblock_child_signal (void) +unblock_child_signal (sigset_t const *oldset) { - pthread_sigmask (SIG_SETMASK, &empty_mask, 0); + pthread_sigmask (SIG_SETMASK, oldset, 0); } /* Return the current buffer's working directory, or the home @@ -162,7 +162,8 @@ void record_kill_process (struct Lisp_Process *p, Lisp_Object tempfile) { - block_child_signal (); + sigset_t oldset; + block_child_signal (&oldset); if (p->alive) { @@ -171,7 +172,7 @@ kill (- p->pid, SIGKILL); } - unblock_child_signal (); + unblock_child_signal (&oldset); } /* Clean up files, file descriptors and processes created by Fcall_process. */ @@ -313,6 +314,7 @@ char *tempfile = NULL; int pid; #else + sigset_t oldset; pid_t pid; #endif int child_errno; @@ -629,7 +631,7 @@ #ifndef MSDOS block_input (); - block_child_signal (); + block_child_signal (&oldset); #ifdef WINDOWSNT pid = child_setup (filefd, fd_output, fd_error, new_argv, 0, current_dir); @@ -671,7 +673,7 @@ if (pid == 0) { - unblock_child_signal (); + unblock_child_signal (&oldset); setsid (); @@ -707,7 +709,7 @@ } } - unblock_child_signal (); + unblock_child_signal (&oldset); unblock_input (); #endif /* not MSDOS */ === modified file 'src/keyboard.c' --- src/keyboard.c 2014-02-24 14:26:49 +0000 +++ src/keyboard.c 2014-02-27 20:23:38 +0000 @@ -10295,6 +10295,9 @@ handle_interrupt (bool in_signal_handler) { char c; + sigset_t blocked; + sigemptyset (&blocked); + sigaddset (&blocked, SIGINT); cancel_echoing (); @@ -10306,9 +10309,6 @@ /* If SIGINT isn't blocked, don't let us be interrupted by a SIGINT. It might be harmful due to non-reentrancy in I/O functions. */ - sigset_t blocked; - sigemptyset (&blocked); - sigaddset (&blocked, SIGINT); pthread_sigmask (SIG_BLOCK, &blocked, 0); } @@ -10393,7 +10393,7 @@ struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; immediate_quit = 0; - pthread_sigmask (SIG_SETMASK, &empty_mask, 0); + pthread_sigmask (SIG_UNBLOCK, &blocked, 0); saved = gl_state; GCPRO4 (saved.object, saved.global_code, saved.current_syntax_table, saved.old_prop); @@ -10414,7 +10414,7 @@ } } - pthread_sigmask (SIG_SETMASK, &empty_mask, 0); + pthread_sigmask (SIG_UNBLOCK, &blocked, 0); /* TODO: The longjmp in this call throws the NS event loop integration off, and it seems to do fine without this. Probably some attention === modified file 'src/lisp.h' --- src/lisp.h 2014-01-03 06:47:27 +0000 +++ src/lisp.h 2014-02-27 20:32:01 +0000 @@ -4237,8 +4237,8 @@ extern void sys_subshell (void); extern void sys_suspend (void); extern void discard_tty_input (void); -extern void block_tty_out_signal (void); -extern void unblock_tty_out_signal (void); +extern void block_tty_out_signal (sigset_t *); +extern void unblock_tty_out_signal (sigset_t const *); extern void init_sys_modes (struct tty_display_info *); extern void reset_sys_modes (struct tty_display_info *); extern void init_all_sys_modes (void); === modified file 'src/process.c' --- src/process.c 2014-02-22 21:08:22 +0000 +++ src/process.c 2014-02-27 20:19:36 +0000 @@ -1660,6 +1660,7 @@ bool pty_flag = 0; char pty_name[PTY_NAME_SIZE]; Lisp_Object lisp_pty_name = Qnil; + sigset_t oldset; inchannel = outchannel = -1; @@ -1725,7 +1726,7 @@ setup_process_coding_systems (process); block_input (); - block_child_signal (); + block_child_signal (&oldset); #ifndef WINDOWSNT /* vfork, and prevent local vars from being clobbered by the vfork. */ @@ -1849,7 +1850,7 @@ signal (SIGPIPE, SIG_DFL); /* Stop blocking SIGCHLD in the child. */ - unblock_child_signal (); + unblock_child_signal (&oldset); if (pty_flag) child_setup_tty (xforkout); @@ -1868,7 +1869,7 @@ p->alive = 1; /* Stop blocking in the parent. */ - unblock_child_signal (); + unblock_child_signal (&oldset); unblock_input (); if (pid < 0) @@ -7055,8 +7056,9 @@ catch_child_signal (void) { struct sigaction action, old_action; + sigset_t oldset; emacs_sigaction_init (&action, deliver_child_signal); - block_child_signal (); + block_child_signal (&oldset); sigaction (SIGCHLD, &action, &old_action); eassert (! (old_action.sa_flags & SA_SIGINFO)); @@ -7065,7 +7067,7 @@ = (old_action.sa_handler == SIG_DFL || old_action.sa_handler == SIG_IGN ? dummy_handler : old_action.sa_handler); - unblock_child_signal (); + unblock_child_signal (&oldset); } === modified file 'src/process.h' --- src/process.h 2014-01-01 07:43:34 +0000 +++ src/process.h 2014-02-27 20:19:31 +0000 @@ -213,8 +213,8 @@ /* Defined in callproc.c. */ -extern void block_child_signal (void); -extern void unblock_child_signal (void); +extern void block_child_signal (sigset_t *); +extern void unblock_child_signal (sigset_t const *); extern Lisp_Object encode_current_directory (void); extern void record_kill_process (struct Lisp_Process *, Lisp_Object); === modified file 'src/sound.c' --- src/sound.c 2014-01-01 07:43:34 +0000 +++ src/sound.c 2014-02-27 20:31:39 +0000 @@ -702,7 +702,7 @@ { int val; #ifdef USABLE_SIGIO - sigset_t blocked; + sigset_t oldset, blocked; #endif eassert (sd->fd >= 0); @@ -714,7 +714,7 @@ #ifdef USABLE_SIGIO sigemptyset (&blocked); sigaddset (&blocked, SIGIO); - pthread_sigmask (SIG_BLOCK, &blocked, 0); + pthread_sigmask (SIG_BLOCK, &blocked, &oldset); #endif val = sd->format; @@ -748,7 +748,7 @@ turn_on_atimers (1); #ifdef USABLE_SIGIO - pthread_sigmask (SIG_UNBLOCK, &blocked, 0); + pthread_sigmask (SIG_SETMASK, &oldset, 0); #endif } @@ -764,10 +764,10 @@ be interrupted by a signal. Block the ones we know to cause troubles. */ #ifdef USABLE_SIGIO - sigset_t blocked; + sigset_t blocked, oldset; sigemptyset (&blocked); sigaddset (&blocked, SIGIO); - pthread_sigmask (SIG_BLOCK, &blocked, 0); + pthread_sigmask (SIG_BLOCK, &blocked, &oldset); #endif turn_on_atimers (0); @@ -776,7 +776,7 @@ turn_on_atimers (1); #ifdef USABLE_SIGIO - pthread_sigmask (SIG_UNBLOCK, &blocked, 0); + pthread_sigmask (SIG_SETMASK, &oldset, 0); #endif /* Close the device. */ === modified file 'src/sysdep.c' --- src/sysdep.c 2014-01-01 07:43:34 +0000 +++ src/sysdep.c 2014-02-27 20:33:23 +0000 @@ -692,21 +692,21 @@ /* Block and unblock SIGTTOU. */ void -block_tty_out_signal (void) +block_tty_out_signal (sigset_t *oldset) { #ifdef SIGTTOU sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGTTOU); - pthread_sigmask (SIG_BLOCK, &blocked, 0); + pthread_sigmask (SIG_BLOCK, &blocked, oldset); #endif } void -unblock_tty_out_signal (void) +unblock_tty_out_signal (sigset_t const *oldset) { #ifdef SIGTTOU - pthread_sigmask (SIG_SETMASK, &empty_mask, 0); + pthread_sigmask (SIG_SETMASK, oldset, 0); #endif } @@ -721,10 +721,11 @@ tcsetpgrp_without_stopping (int fd, pid_t pgid) { #ifdef SIGTTOU + sigset_t oldset; block_input (); - block_tty_out_signal (); + block_tty_out_signal (&oldset); tcsetpgrp (fd, pgid); - unblock_tty_out_signal (); + unblock_tty_out_signal (&oldset); unblock_input (); #endif } @@ -1525,9 +1526,6 @@ #endif } - if (! IEEE_FLOATING_POINT) - sigaddset (&action->sa_mask, SIGFPE); - action->sa_handler = handler; action->sa_flags = emacs_sigaction_flags (); } @@ -1643,7 +1641,10 @@ static _Noreturn void handle_arith_signal (int sig) { - pthread_sigmask (SIG_SETMASK, &empty_mask, 0); + sigset_t blocked; + sigemptyset (&blocked); + sigaddset (&blocked, sig); + pthread_sigmask (SIG_UNBLOCK, &blocked, 0); xsignal0 (Qarith_error); } === modified file 'src/term.c' --- src/term.c 2014-01-25 08:25:51 +0000 +++ src/term.c 2014-02-27 20:33:17 +0000 @@ -3952,9 +3952,10 @@ /* setsid failed, presumably because Emacs is already a process group leader. Fall back on the obsolescent way to dissociate a controlling tty. */ - block_tty_out_signal (); + sigset_t oldset; + block_tty_out_signal (&oldset); ioctl (fd, TIOCNOTTY, 0); - unblock_tty_out_signal (); + unblock_tty_out_signal (&oldset); #endif } } @@ -3978,6 +3979,7 @@ int status; struct tty_display_info *tty = NULL; struct terminal *terminal = NULL; + sigset_t oldset; bool ctty = false; /* True if asked to open controlling tty. */ if (!terminal_type) @@ -4064,11 +4066,11 @@ /* On some systems, tgetent tries to access the controlling terminal. */ - block_tty_out_signal (); + block_tty_out_signal (&oldset); status = tgetent (tty->termcap_term_buffer, terminal_type); if (tty->termcap_term_buffer[TERMCAP_BUFFER_SIZE - 1]) emacs_abort (); - unblock_tty_out_signal (); + unblock_tty_out_signal (&oldset); if (status < 0) { --------------000307030603030600000309--