From: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: grep-use-null-device
Date: Thu, 01 Sep 2005 10:59:48 -0400 [thread overview]
Message-ID: <jwvaciwzvvg.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87mzmy1wmh.fsf@jurta.org> (Juri Linkov's message of "Wed, 31 Aug 2005 09:02:22 +0300")
>>> `compilation-start' needs to check if the process is running
>>> before calling `process-send-eof':
>>
>> That's odd. AFAICT no blobking operation takes place between the
>> start-process and the process-send-eof, so the process-status should still
>> be `run' no matter how quickly the process exits (because Emacs shouldn't
>> process the SIGCHLD it receives until later).
>>
>> What am I missing?
> The process exits during execution of create_process. The gdb log below
> with a breakpoint on sigchld_handler demonstrates what really happens:
> Breakpoint 4, sigchld_handler (signo=17) at process.c:6249
> 6249 XSETINT (p->raw_status_low, u.i & 0xffff);
> (gdb) n
> 6250 XSETINT (p->raw_status_high, u.i >> 16);
> (gdb) n
> 6253 if ((WIFSIGNALED (w) || WIFEXITED (w))
> (gdb) n
> 6260 FD_CLR (XINT (p->infd), &input_wait_mask);
> (gdb) n
> 6261 FD_CLR (XINT (p->infd), &non_keyboard_wait_mask);
> (gdb) p w
> $1 = 512 <-- WIFEXITED
> (gdb) bt
> #0 sigchld_handler (signo=17) at process.c:6261
> #1 <signal handler called>
> #2 0x4031f784 in sigprocmask () from /lib/libc.so.6
> #3 0x0817af28 in create_process (process=141365940, new_argv=0xbfffe954, current_dir=140249731) at process.c:2153
> #4 0x0817a97d in Fstart_process (nargs=5, args=0xbfffea94) at process.c:1695
> ...
> (gdb) fr 3
> #3 0x0817af28 in create_process (process=141365940, new_argv=0xbfffe954, current_dir=140249731) at process.c:2153
> 2153 sigprocmask (SIG_SETMASK, &procmask, 0);
Oh, I now see that process-send-eof does:
if (! NILP (XPROCESS (proc)->raw_status_low))
update_status (XPROCESS (proc));
which basically copies the asynchronously updated proc->raw_status_* to the
synchronously updated proc->status.
Since this process status can change asynchronously, adding your test
for (eq (process-status proc) 'run) before calling process-send-eof doesn't
fix the bug but just narrows the window of the race condition because the
status can still change between the call to process-status and the call to
process-send-eof.
So I suggest the patch below instead,
Stefan
--- compile.el 01 sep 2005 10:04:39 -0400 1.379
+++ compile.el 01 sep 2005 10:58:22 -0400
@@ -1038,11 +1038,14 @@
outbuf command))))
;; Make the buffer's mode line show process state.
(setq mode-line-process '(":%s"))
- (when compilation-disable-input
- (process-send-eof proc))
(set-process-sentinel proc 'compilation-sentinel)
(set-process-filter proc 'compilation-filter)
(set-marker (process-mark proc) (point) outbuf)
+ (when compilation-disable-input
+ (condition-case nil
+ (process-send-eof proc)
+ ;; The process may have exited already.
+ (error nil)))
(setq compilation-in-progress
(cons proc compilation-in-progress)))
;; No asynchronous processes available.
next prev parent reply other threads:[~2005-09-01 14:59 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-15 15:41 grep-use-null-device Emilio Lopes
2005-08-16 2:25 ` grep-use-null-device Richard M. Stallman
2005-08-16 11:46 ` grep-use-null-device Karl Chen
2005-08-16 16:20 ` grep-use-null-device Emilio Lopes
2005-08-17 6:25 ` grep-use-null-device Richard M. Stallman
2005-08-20 12:22 ` grep-use-null-device Eli Zaretskii
2005-08-27 1:30 ` "^D^H^H" in process output on Darwin (Was Re: grep-use-null-device) YAMAMOTO Mitsuharu
2005-08-29 13:56 ` "^D^H^H" in process output on Darwin Stefan Monnier
2005-09-13 8:21 ` Nozomu Ando
2005-09-17 1:33 ` YAMAMOTO Mitsuharu
2005-08-29 22:43 ` grep-use-null-device Juri Linkov
2005-08-30 10:30 ` grep-use-null-device Richard M. Stallman
2005-08-31 2:31 ` grep-use-null-device Stefan Monnier
2005-08-31 6:02 ` grep-use-null-device Juri Linkov
2005-09-01 14:59 ` Stefan Monnier [this message]
2005-09-01 16:16 ` grep-use-null-device David Kastrup
2005-09-01 18:18 ` grep-use-null-device Stefan Monnier
2005-09-03 1:43 ` grep-use-null-device Richard M. Stallman
2005-08-16 7:15 ` grep-use-null-device Emilio Lopes
2005-08-16 9:26 ` grep-use-null-device David Kastrup
2005-08-16 16:29 ` grep-use-null-device Emilio Lopes
2005-08-16 9:45 ` grep-use-null-device Juri Linkov
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=jwvaciwzvvg.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.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.