michael.cadilhac@lrde.org (Michaël Cadilhac) writes: > Stefan Monnier writes: > >> BTW, did anyone actually test my code to make sure that it does indeed work >> and fix the problem? >> >> Stefan > > As far as I tested, it doesn't work and freeze my Emacs. I'll > investigate today. I fixed what we discussed here. I found two bugs in your proposal: - the list was set to Qnil at the wrong place (wrong init) - `return' was used in the handler, but it could still have some process to treat (a continue would have been better but still wrong). A patch is attached. However, the whole thing still doesn't work ; Emacs freezes or prints this kind of error message: Error in post-command-hook: (wrong-type-argument listp (nil DEAD . 18764377)) I thought that the race condition could be the following: - delq makes some change on the list but not all, - It is interrupted by the handler, - The handler now has to deal with a malformed list. It's certainly a bug too, as with the delq I had some Abort in the handler of the form: #0 0xb7a45951 in kill () from /lib/libc.so.6 #1 0x080eb75c in abort () at emacs.c:464 #2 0x081536b2 in Fsignal (error_symbol=137610425, data=137557813) at eval.c:1616 #3 0x081402ce in wrong_type_argument (predicate=137622913, value=149282605) at data.c:124 #4 0x0815c175 in Fmember (elt=71112, list=149282605) at fns.c:1468 #5 0x0818577c in sigchld_handler (signo=17) at process.c:6390 Which I think I don't have without, however, it is not the only error, as with this line deleted, I still have the previous error and problems. For example, I don't think it's normal for emacs to receive a SIGPIPE #0 0xb7ba62b8 in write () from /lib/libpthread.so.0 #1 0x00000002 in ?? () #2 0x0810561e in emacs_write (fildes=12, buf=0x8d26178 "!\n", nbyte=12) at sysdep.c:3370 #3 0x08187afb in send_process (proc=150054228, buf=0x8d26178 "!\n", len=2, object=149437363) at process.c:5489 #4 0x08188274 in Fprocess_send_string (process=150054228, string=149437363) at process.c:5643 #5 0x081534cb in Ffuncall (nargs=3, args=0xbfea69b4) at eval.c:2905 ... Alas, most of the backtraces only show Emacs blocked in select, pthread things or wait_for_termination. If any hacker can help :-) Maybe it's not the good solution to keep traces of these. The other possibility (if we don't consider the wait_for_termination solution), is to store the PID of the synchronous process ; but I'm confused with compatibilities with DOS and Mac :-/ If we have the PID of the synchronous process, we can explicitly test it in sigchld_handler.