1. 05 Jun, 2013 1 commit
  2. 03 Jun, 2013 1 commit
    • Michael Albinus's avatar
      * configure.ac (file-notification): New option, replaces inotify option. · c9628c79
      Michael Albinus authored
      (HAVE_W32): Remove w32notify.o.
      (with_file_notification): Add checks for glib and w32. Adapt check
      for inotify.
      (Summary): Add entry for file notification.
      
      * autogen/config.in: Add entries for HAVE_GFILENOTIFY,
      HAVE_W32NOTIFY and USE_FILE_NOTIFY.
      
      * lisp/autorevert.el (auto-revert-notify-enabled)
      (auto-revert-notify-rm-watch, auto-revert-notify-add-watch)
      (auto-revert-notify-event-p, auto-revert-notify-event-file-name)
      (auto-revert-notify-handler): Handle also gfilenotify.
      
      * lisp/subr.el: (file-notify-handle-event): New defun. Replacing ...
      (inotify-event-p, inotify-handle-event, w32notify-handle-event):
      Removed.
      
      * src/Makefile.in (NOTIFY_OBJ): New variable.
      (base_obj): Replace inotify.o by $(NOTIFY_OBJ).
      
      * src/emacs.c (main): Use HAVE_W32NOTIFY to wrap respective code.
      Call syms_of_gfilenotify.
      
      * src/gfilenotify.c: New file.
      
      * src/keyboard.c (Qfile_notify): New variable.  Replaces Qfile_inotify
      and Qfile_w32notify.
      (top): Wrap respective code by HAVE_GFILENOTIFY, HAVE_INOTIFY,
      HAVE_W32NOTIFY and USE_FILE_NOTIFY.
      
      * src/lisp.h: Declare syms_of_gfilenotify.
      
      * src/termhooks.h (e): Wrap enum by USE_FILE_NOTIFY.
      c9628c79
  3. 19 Mar, 2013 1 commit
  4. 13 Mar, 2013 1 commit
  5. 25 Feb, 2013 1 commit
    • Paul Eggert's avatar
      Simplify data_start configuration. · 1ddc2bd6
      Paul Eggert authored
      This is a followon simplification to the fix for Bug#13650.
      * admin/CPP-DEFINES (DATA_START, ORDINARY_LINK): Remove.
      * configure.ac (CRT_DIR, LIB_STANDARD, START_FILES, DATA_START)
      (LD_FIRSTFLAG, ORDINARY_LINK, LIB_GCC): Remove.
      (AC_CHECK_HEADERS_ONCE): Remove sys/resource.h, as it's
      not always needed.
      (HAVE_DATA_START): New macro.
      * etc/PROBLEMS (LIBS_SYSTEM, LIBS_MACHINE, LIBS_STANDARD): Remove.
      Remove legacy-systems section, as this stuff is no longer
      applicable with current linking strategies.
      * src/Makefile.in (LD_FIRSTFLAG, LIB_GCC, CRT_DIR, LIB_STANDARD)
      (START_FILES): Remove.  All uses removed.
      (otherobj): Remove $(VMLIMIT_OBJ), as it's now first.
      (ALLOBJS): Move here from autodeps.mk, and with VMLIMITS_OBJ first.
      (buildobj.h): Use it.
      ($(ALLOBJS)): Depend on globals.h.
      (temacs$(EXEEXT)): Use $(ALLOBJS).
      * src/autodeps.mk (ALLOBJS): Move to Makefile.in.
      * src/deps.mk (vm-limit.o):
      * src/makefile.w32-in ($(BLD)/vm-limit.$(O)):
      Do not depend on mem-limits.h.
      * src/emacs.c (__do_global_ctors, __do_global_ctors_aux)
      (__do_global_dtors, __CTOR_LIST__, __DTOR_LIST__)
      [__GNUC__ && !ORDINARY_LINK]: Remove.
      * src/mem-limits.h, src/pre-crt0.c: Remove.
      * src/unexaix.c, src/unexcoff.c: Don't include mem-limits.h.
      * src/unexcoff.c (etext): New decl.
      (make_hdr): Use it instead of start_of_data.
      * src/vm-limit.c: Move most of mem-limits.h's contents here.
      (data_start): New decl.  It's OK if this is approximate,
      so simplify-away some unnecessary exactness.
      (POINTER): Remove; all uses removed.
      (data_space_start): Now char *, to avoid casts.
      (exceeds_lisp_ptr): New function, replacing the old
      EXCEEDS_LISP_PTR macro.  All uses changed.
      (check_memory_limits): Simplify and remove casts.
      (start_of_data) [!CANNOT_DUMP || !SYSTEM_MALLOC]: Remove.
      (memory_warnings): Use data_start instead of start_of_data.
      
      Fixes: debbugs:13783
      1ddc2bd6
  6. 05 Feb, 2013 1 commit
  7. 03 Feb, 2013 1 commit
  8. 02 Feb, 2013 1 commit
    • Eli Zaretskii's avatar
      Avoid encoding file names run through dostounix_filename on MS-Windows. · e7ac588e
      Eli Zaretskii authored
       src/w32.c (normalize_filename): Accept an additional argument
       MULTIBYTE; if non-zero, traverse the file name by bytes and don't
       downcase it even if w32-downcase-file-names is non-nil.
       (dostounix_filename): Accept an additional argument MULTIBYTE and
       pass it to normalize_filename.
       (emacs_root_dir): Adjust.
       src/msdos.h (dostounix_filename): Adjust prototype.
       src/w32.h (dostounix_filename): Adjust prototype.
       src/msdos.c (dostounix_filename): Accept an additional argument and
       ignore it.
       (init_environment): Adjust callers of dostounix_filename.
       src/fileio.c (Ffile_name_directory, file_name_as_directory)
       (directory_file_name, Fexpand_file_name)
       (Fsubstitute_in_file_name): [DOS_NT] Adjust call to
       dostounix_filename.
       [WINDOWSNT]: Downcase file names if w32-downcase-file-names is
       non-nil.
       (Fsubstitute_in_file_name): [DOS_NT] Don't downcase environment
       variables, as egetenv is case-insensitive for DOS_NT.
       src/dired.c (file_name_completion): Don't call Fdirectory_file_name
       with an encoded file name.
       src/w32proc.c (Fw32_short_file_name, Fw32_long_file_name): Adjust
       calls to dostounix_filename.
       src/w32fns.c (Fx_file_dialog): Adjust call to dostounix_filename.
       src/unexw32.c (unexec): Adjust call to dostounix_filename.
       src/termcap.c (tgetent) [MSDOS]: Adjust call to dostounix_filename.
       src/emacs.c (decode_env_path) [DOS_NT]: Adjust call to
       dostounix_filename.
       src/callproc.c (Fcall_process) [MSDOS]: Adjust call to
       dostounix_filename.
      e7ac588e
  9. 22 Jan, 2013 1 commit
  10. 19 Jan, 2013 2 commits
    • Chong Yidong's avatar
      73c14218
    • Paul Eggert's avatar
      Work around bug in CIFS and vboxsf file systems. · 9fe43ff6
      Paul Eggert authored
      The bug was observed on Ubuntu operating inside a virtual machine,
      editing files mounted via CIFS or vboxsf from the MS Windows 7 host.
      The workaround introduces a race condition on non-buggy hosts,
      but it's an unlikely race and anyway there's a nearly identical
      nearby race that can't be fixed.
      * fileio.c (valid_timestamp_file_system, timestamp_file_system):
      New static vars.
      (Fwrite_region): Test for file system time stamp bug.
      (init_fileio): New function.
      * lisp.h (init_fileio): Declare it.
      * emacs.c (main): Call it.
      
      Fixes: debbugs:13149
      9fe43ff6
  11. 11 Jan, 2013 1 commit
    • Paul Eggert's avatar
      Fix SIGDANGER handlers, for AIX. · b6f960a0
      Paul Eggert authored
      * sysdep.c.c (handle_danger_signal, deliver_danger_signal) [SIGDANGER]:
      Move handlers here from emacs.c; they were out of place.
      
      Fixes: debbugs:13408
      b6f960a0
  12. 01 Jan, 2013 1 commit
  13. 10 Dec, 2012 3 commits
    • Daniel Colascione's avatar
      Move fix for bug#12993 to trunk · 78f9ea87
      Daniel Colascione authored
      78f9ea87
    • Rüdiger Sonderfeld's avatar
      Support filesystem notification through inotify on GNU/Linux. · 81606b10
      Rüdiger Sonderfeld authored
       configure.ac (inotify): New option.
       (HAVE_INOTIFY): Test for inotify.
      
       src/termhooks.h (enum event_kind) [HAVE_INOTIFY]: Add
       FILE_NOTIFY_EVENT.
       src/lisp.h (syms_of_inotify) [HAVE_INOTIFY]: Add prototype.
       src/keyboard.c (Qfile_inotify) [HAVE_INOTIFY]: New variable.
       (syms_of_keyboard): DEFSYM it.
       (kbd_buffer_get_event) [HAVE_INOTIFY]: Generate FILE_NOTIFY_EVENT.
       (make_lispy_event): Support FILE_NOTIFY_EVENT by generating
       Qfile_inotify events.
       (keys_of_keyboard) [HAVE_INOTIFY]: Bind file-inotify events in
       special-event-map to inotify-handle-event.
       src/emacs.c (main) [HAVE_INOTIFY]: Call syms_of_inotify.
       src/Makefile.in (base_obj): Add inotify.o.
       src/inotify.c: New file.
      
       lisp/subr.el (inotify-event-p, inotify-handle-event): New functions.
      
       test/automated/inotify-test.el: New test.
      81606b10
    • Daniel Colascione's avatar
      1cf1bbd5
  14. 08 Dec, 2012 1 commit
    • Paul Eggert's avatar
      Use putenv+unsetenv instead of modifying environ directly. · 5745a7df
      Paul Eggert authored
      * admin/merge-gnulib (GNULIB_MODULES): Add putenv, unsetenv.
      * lib/putenv.c, lib/unsetenv.c, m4/putenv.m4, m4/setenv.m4:
      New files, copied automatically from gnulib.
      * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
      * src/alloc.c (xputenv): New function.
      * src/dbusbind.c (Fdbus_init_bus):
      * src/emacs.c (main):
      * src/xterm.c (x_term_init):
      Use xputenv instead of setenv or putenv, to detect memory exhaustion.
      * src/editfns.c (initial_tz): Move static var decl up.
      (tzvalbuf_in_environ): New static var.
      (init_editfns):	Initialize these two static vars.
      (Fencode_time): Don't assume arbitrary limit on EMACS_INT width.
      Save old TZ value on stack, if it's small.
      (Fencode_time, set_time_zone_rule): Don't modify 'environ' directly;
      instead, use xputenv+unsetenv to set and restore TZ.
      (environbuf): Remove static var.  All uses removed.
      (Fset_time_zone_rule): Do not save TZ and environ;
      no longer needed here.
      (set_time_zone_rule_tz1, set_time_zone_rule_tz2) [LOCALTIME_CACHE]:
      Move to inside set_time_zone_rule; they don't need file scope any more.
      (set_time_zone_rule): Maintain the TZ=value string separately.
      (syms_of_editfns): Don't initialize initial_tz;
      init_editfns now does it.
      * src/emacs.c (dump_tz) [HAVE_TZSET]: Now const.
      * src/lisp.h (xputenv): New decl.
      
      Fixes: debbugs:13070
      5745a7df
  15. 20 Nov, 2012 1 commit
  16. 17 Nov, 2012 1 commit
    • Paul Eggert's avatar
      Assume POSIX 1003.1-1988 or later for fcntl.h. · 49cdacda
      Paul Eggert authored
      * admin/CPP-DEFINES (O_RDONLY, O_RDWR, HAVE_FCNTL_H): Remove.
      * admin/merge-gnulib (GNULIB_MODULES): Add fcntl-h.
      * configure.ac: Do not check for fcntl.h.
      * lib/gnulib.mk: Regenerate.
      * lib-src/movemail.c, lib-src/update-game-score.c: Assume <fcntl.h> exists.
      * nt/inc/sys/socket.h (O_NONBLOCK): Rename from O_NDELAY, since the
      POSIX name for this flag is O_NONBLOCK.  All uses changed.
      * nt/inc/unistd.h (O_RDWR, O_NOCTTY): New macros.  Like AT_FDCWD etc.
      these really should be moved to a replacement <fcntl.h> if and
      when that gets implemented.  In the meantime, include <fcntl.h>
      to make sure we don't override its definitions.
      * src/callproc.c (relocate_fd): Assume F_DUPFD.
      * src/emacs.c, src/term.c (O_RDWR): Remove.
      * src/keyboard.c (tty_read_avail_input): Use O_NONBLOCK rather than
      O_NDELAY, since O_NONBLOCK is the standard name for this flag.
      * src/nsterm.m: Assume <fcntl.h> exists.
      * src/process.c (NON_BLOCKING_CONNECT, allocate_pty, create_process)
      (create_pty, Fmake_network_process, server_accept_connection)
      (wait_reading_process_output, init_process_emacs):
      Assume O_NONBLOCK.
      (wait_reading_process_output): Put in a special case for WINDOWSNT
      to mimick the older behavior where it had O_NDELAY but not O_NONBLOCK.
      It's not clear this is needed, but it's a more-conservative change.
      (create_process): Assume FD_CLOEXEC.
      (create_process, create_pty): Assume O_NOCTTY.
      * src/sysdep.c (init_sys_modes, reset_sys_modes): Assume F_SETFL.
      (reset_sys_modes): Use O_NONBLOCK rather than O_NDELAY.
      Omit if not DOS_NT, since F_GETFL is not defined there.
      (serial_open): Assume O_NONBLOCK and O_NOCTTY.
      * src/term.c: Include <fcntl.h>, for flags like O_NOCTTY.
      (O_NOCTTY): Remove.
      (init_tty): Assume O_IGNORE_CTTY is defined to 0 on platforms that
      lack it, since gnulib guarantees this.
      * src/w32.c (fcntl): Test for O_NONBLOCK rather than O_NDELAY.
      
      Fixes: debbugs:12881
      49cdacda
  17. 08 Nov, 2012 1 commit
    • Stefan Monnier's avatar
      Use ad-hoc comparison function for the profiler's hash-tables. · b7432bb2
      Stefan Monnier authored
      * src/profiler.c (Qprofiler_backtrace_equal, hashtest_profiler): New vars.
      (make_log): Use them.
      (handle_profiler_signal): Don't inhibit quit any longer since we don't
      call Fequal any more.
      (Ffunction_equal): New function.
      (cmpfn_profiler, hashfn_profiler): New functions.
      (syms_of_profiler): Initialize them.
      * src/lisp.h (struct hash_table_test): New struct.
      (struct Lisp_Hash_Table): Use it.
      * src/alloc.c (mark_object): Mark hash_table_test fields of hash tables.
      * src/fns.c (make_hash_table): Take a struct to describe the test.
      (cmpfn_eql, cmpfn_equal, cmpfn_user_defined, hashfn_eq, hashfn_eql)
      (hashfn_equal, hashfn_user_defined): Adjust to new calling convention.
      (hash_lookup, hash_remove_from_table): Move assertion checking of
      hashfn result here.  Check hash-equality before calling cmpfn.
      (Fmake_hash_table): Adjust call to make_hash_table.
      (hashtest_eq, hashtest_eql, hashtest_equal): New structs.
      (syms_of_fns): Initialize them.
      * src/emacs.c (main): Move syms_of_fns earlier.
      * src/xterm.c (syms_of_xterm):
      * src/category.c (hash_get_category_set): Adjust call to make_hash_table.
      * src/print.c (print_object): Adjust to new hash-table struct.
      * src/composite.c (composition_gstring_put_cache): Adjust to new hashfn.
      b7432bb2
  18. 05 Nov, 2012 1 commit
    • Paul Eggert's avatar
      Assume at least POSIX.1-1988 for getpgrp, setpgid, setsid. · dd0333b6
      Paul Eggert authored
      This removes code that has been obsolete since around 1990.
      * admin/CPP-DEFINES (HAVE_SETPGID, HAVE_SETSID, SETPGRP_RELEASES_CTTY):
      Remove; obsolete.
      * configure.ac (setpgid, setsid): Assume their existence.
      (AC_FUNC_GETPGRP, SETPGRP_RELEASES_CTTY): Remove; obsolete.
      * src/callproc.c (Fcall_process):
      * src/emacs.c (main):
      * src/process.c (create_process):
      * src/term.c (dissociate_if_controlling_tty):
      Assume setsid exists.
      * src/callproc.c (child_setup): Assume setpgid exists and behaves as
      per POSIX.1-1988 or later.
      * src/conf_post.h (setpgid) [!HAVE_SETPGID]: Remove.
      * src/emacs.c (shut_down_emacs):
      * src/sysdep.c (sys_suspend, init_foreground_group):
      Assume getpgrp behaves as per POSIX.1-1998 or later.
      * src/msdos.c (setpgrp): Remove.
      (tcgetpgrp, setpgid, setsid): New functions.
      * src/systty.h (EMACS_GETPGRP): Remove.  All callers now use getpgrp.
      * src/term.c (no_controlling_tty): Remove; unused.
      * src/w32proc.c (setpgrp): Remove.
      (setsid, tcgetpgrp): New functions.
      
      Fixes: debbugs:12800
      dd0333b6
  19. 04 Nov, 2012 1 commit
    • Paul Eggert's avatar
      Fix data-loss with --version. · 76abf5e5
      Paul Eggert authored
      * emacs.c (close_output_streams): Use strerror, not emacs_strerror,
      as we can't assume that emacs_strerror is initialized, and strerror
      is good enough here.
      (main): Invoke atexit earlier, to catch earlier instances of
      sending data to stdout and exiting, e.g., "emacs --version >/dev/full".
      
      Fixes: debbugs:9574
      76abf5e5
  20. 03 Nov, 2012 1 commit
    • Paul Eggert's avatar
      Fix data-loss with --batch. · 7ccfb720
      Paul Eggert authored
      * admin/merge-gnulib (GNULIB_MODULES): Add close-stream.
      * lib/close-stream.c, lib/close-stream.h, lib/fpending.c
      * lib/fpending.h, m4/close-stream.m4, m4/fpending.m4:
      New files, from gnulib.
      * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
      * src/emacs.c: Include <close-stream.h>.
      (close_output_streams): New function.
      (main): Pass it to atexit, so that Emacs closes stdout and stderr
      and handles errors appropriately.
      (Fkill_emacs): Don't worry about flushing, as close_output_stream
      does that now.
      
      Fixes: debbugs:9574
      7ccfb720
  21. 31 Oct, 2012 1 commit
    • Paul Eggert's avatar
      Fix crash when using Emacs as commit editor for git. · 322aea6d
      Paul Eggert authored
      * callproc.c (setpgrp): Remove macro, as we now use setpgid
      and it is configured in conf_post.h.
      (Fcall_process): Don't invoke both setsid and setpgid; the former
      is enough, if it exists.
      * callproc.c (Fcall_process, child_setup):
      * process.c (create_process): Use setpgid.
      * conf_post.h (setpgid) [!HAVE_SETPGID]: New macro, which substitutes
      for the real thing.
      * dispnew.c (init_display): Initialize the foreground group
      if we are running a tty display.
      * emacs.c (main): Do not worry about setpgrp; init_display does it now.
      * lisp.h (init_foreground_group): New decl.
      * sysdep.c (inherited_pgroup): New static var.
      (init_foreground_group, tcsetpgrp_without_stopping)
      (narrow_foreground_group, widen_foreground_group): New functions.
      (init_sys_modes): Narrow foreground group.
      (reset_sys_modes): Widen foreground group.
      
      Fixes: debbugs:12697
      322aea6d
  22. 25 Oct, 2012 1 commit
    • Paul Eggert's avatar
      Don't assume process IDs fit in int. · 69deda53
      Paul Eggert authored
      * emacs.c (shut_down_emacs) [!DOS_NT]:
      * sysdep.c (sys_suspend) [SIGTSTP && !MSDOS]:
      * term.c (dissociate_if_controlling_tty) [!DOS_NT]:
      Use pid_t, not int, to store process IDs, as 'int'
      is not wide enough on a few platforms (e.g., AIX and IRIX).
      69deda53
  23. 14 Oct, 2012 1 commit
  24. 08 Oct, 2012 3 commits
  25. 06 Oct, 2012 1 commit
    • Eli Zaretskii's avatar
      Initial version of the w32notify code. · 477f1e50
      Eli Zaretskii authored
      Adding and removing a watch seems to work: a new thread is launched
      when a watch is added and exits when the watch is removed.
      But there are no notifications, so it seems.  At least, the Lisp
      callback function passed to w32notify-add-watch is not called.
      477f1e50
  26. 01 Oct, 2012 3 commits
    • Paul Eggert's avatar
      Fix a malloc race condition involving strsignal. · aa1ba90e
      Paul Eggert authored
      A signal can arrive in the middle of a malloc, and Emacs's signal
      handler can invoke strsignal, which can invoke malloc, which is
      not portable.  This race condition bug makes Emacs hang on GNU/Linux.
      Fix it by altering the signal handler so that it does not invoke
      strsignal.
      * emacs.c (shut_down_emacs): Use safe_strsignal, not strsignal.
      * process.c (status_message): Use const pointer, in case strsignal
      is #defined to safe_strsignal.
      * sysdep.c (sys_siglist, init_signals): Always define and
      initialize a substitute sys_siglist if the system does not define
      one, even if HAVE_STRSIGNAL.
      (safe_strsignal): Rename from strsignal.  Always define,
      using sys_siglist.  Return a const pointer.
      * syssignal.h (safe_strsignal): New decl.
      (strsignal) [!HAVE_STRSIGNAL]: Define in terms of safe_strsignal.
      aa1ba90e
    • Fabrice Popineau's avatar
      Fix minor compilation problem with MSVC. · b3317662
      Fabrice Popineau authored
       src/emacs.c: Move the inclusion of TERM_HEADER after including
       windows.h on WINDOWSNT.  This avoids compilation problems with
       MSVC.
      b3317662
    • Eli Zaretskii's avatar
      Fix termination sequence on Windows wrt interval timers. · f0e5f225
      Eli Zaretskii authored
       src/w32proc.c <disable_itimers>: New static flag.
       (init_timers): Initialize it to zero, after creating the critical
       sections used by the timer threads.
       (term_timers): Set to 1 before deleting the critical sections.
       (getitimer, setitimer): If disable_itimers is non-zero, return an
       error indication without doing anything.  Reported by Fabrice
       Popineau <fabrice.popineau@supelec.fr> as part of bug#12544.
      f0e5f225
  27. 25 Sep, 2012 2 commits
    • Juanma Barranquero's avatar
      Move Vlibrary_cache to emacs.c and reset before dumping. · aa15c6bb
      Juanma Barranquero authored
      * src/lisp.h (reset_image_types): Declare.
      [WINDOWSNT] (Vlibrary_cache): Declare.
      
      * src/image.c (reset_image_types): New function.
      
      * src/emacs.c [WINDOWSNT] (Vlibrary_cache): Move from w32.c.
      (syms_of_emacs) [WINDOWSNT] <Vlibrary_cache>: Initialize and staticpro.
      (Fdump_emacs): Reset Vlibrary_cache and image_types.
      
      * src/w32.c (Vlibrary_cache): Do not define; moved to emacs.c
      (globals_of_w32) <Vlibrary_cache>: Do not initialize.
      
      * src/w32.h (Vlibrary_cache): Do not declare.
      aa15c6bb
    • Eli Zaretskii's avatar
      Fix handling of fatal signals and exceptions on MS-Windows. · 16b22fef
      Eli Zaretskii authored
       src/w32proc.c (sys_signal): Handle all signals defined by the
       MS-Windows runtime, not just SIGCHLD.  Actually install the signal
       handlers for signals supported by Windows.  Don't override
       term_ntproc as the handler for SIGABRT.
       (sigaction): Rewrite to call sys_signal instead of duplicating its
       code.
       (sys_kill): Improve commentary.
       src/w32.c (term_ntproc): Accept (and ignore) one argument, for
       consistency with a signature of a signal handler.  All callers
       changed.
       (init_ntproc): Accept an argument DUMPING.  If dumping, don't
       install term_ntproc as a signal handler for SIGABRT, as that
       should be done by the dumped Emacs.
       src/w32.h (init_ntproc, term_ntproc): Adjust prototypes.
       src/w32select.c (term_w32select): Protect against repeated
       invocation by setting clipboard_owner to NULL after calling
       DestroyWindow.
       src/emacs.c (shut_down_emacs, main): Adapt the calls to init_ntproc
       and term_ntproc to their modified signatures.
      16b22fef
  28. 23 Sep, 2012 2 commits
    • Paul Eggert's avatar
      Do not use SA_NODEFER. · 62a1d661
      Paul Eggert authored
      Problem reported by Dani Moncayo in
      <http://lists.gnu.org/archive/html/emacs-devel/2012-09/msg00557.html>.
      * alloc.c (die):
      * sysdep.c (emacs_abort): Do not reset signal handler.
      * emacs.c (terminate_due_to_signal): Reset signal handler here.
      * sysdep.c (init_signals): Do not use SA_NODEFER.  It wasn't
      wanted even on POSIXish hosts, and it doesn't work on Windows.
      62a1d661
    • Paul Eggert's avatar
      Simplify and avoid signal-handling races. · 4d7e6e51
      Paul Eggert authored
      * nt/inc/ms-w32.h (emacs_raise): New macro.
      * src/alloc.c (die):
      * src/sysdep.c (emacs_abort) [HAVE_NTGUI]:
      Avoid recursive loop if there's a fatal error in the function itself.
      * src/atimer.c (pending_atimers):
      * src/blockinput.h: Don't include "atimer.h"; no longer needed.
      (interrupt_input_pending): Remove.  All uses removed.
      pending_signals now counts both atimers and ordinary interrupts.
      This is less racy than having three separate pending-signal flags.
      (block_input, unblock_input, totally_unblock_input, unblock_input_to)
      (input_blocked_p):
      Rename from their upper-case counterparts BLOCK_INPUT,
      UNBLOCK_INPUT, TOTALLY_UNBLOCK_INPUT, UNBLOCK_INPUT_TO,
      INPUT_BLOCKED_P, and turn into functions.  All uses changed.
      This makes it easier to access volatile variables more accurately.
      (BLOCK_INPUT_RESIGNAL): Remove.  All uses replaced by unblock_input ().
      (input_blocked_p): Prefer this to 'interrupt_input_blocked', as
      that's more reliable if the code is buggy and sets
      interrupt_input_blocked to a negative value.  All uses changed.
      * src/atimer.c (deliver_alarm_signal):
      Remove.  No need to deliver this to the parent; any thread can
      handle this signal now.  All uses replaced by underlying handler.
      * src/atimer.c (turn_on_atimers):
      * src/dispnew.c (handle_window_change_signal):
      * src/emacs.c (handle_danger_signal):
      * src/keyboard.c (kbd_buffer_get_event):
      Don't reestablish signal handler; not needed with sigaction.
      * src/blockinput.h (UNBLOCK_INPUT_TO, TOTALLY_UNBLOCK_INPUT)
      (UNBLOCK_INPUT_TO):
      Rework to avoid unnecessary accesses to volatile variables.
      (UNBLOCK_INPUT_TO): Now a function.
      (totally_unblock_input, unblock_input): New decls.
      * src/data.c (handle_arith_signal, deliver_arith_signal): Move to sysdep.c
      (init_data): Remove.  Necessary stuff now done in init_signal.
      * src/emacs.c, src/xdisp.c: Include "atimer.h", since we invoke atimer functions.
      * src/emacs.c (handle_fatal_signal, deliver_fatal_signal): Move to sysdep.c.
      (fatal_error_code): Remove; no longer needed.
      (terminate_due_to_signal): Rename from fatal_error_backtrace, since
      it doesn't always backtrace.  All uses changed.  No need to reset
      signal to default, since sigaction and/or die does that for us now.
      Use emacs_raise (FOO), not kill (getpid (), FOO).
      (main): Check more-accurately whether we're dumping.
      Move fatal-error setup to sysdep.c
      * src/floatfns.c: Do not include "syssignal.h"; no longer needed.
      * src/gtkutil.c (xg_get_file_name, xg_get_font):
      Remove no-longer-needed signal-mask manipulation.
      * src/keyboard.c, src/process.c (POLL_FOR_INPUT):
      Don't depend on USE_ASYNC_EVENTS, a symbol that is never defined.
      * src/keyboard.c (read_avail_input): Remove.
      All uses replaced by gobble_input.
      (Ftop_level): Use TOTALLY_UNBLOCK_INPUT rather than open code.
      (kbd_buffer_store_event_hold, gobble_input):
      (record_asynch_buffer_change) [USABLE_SIGIO]:
      (store_user_signal_events):
      No need to mess with signal mask.
      (gobble_input): If blocking input and there are terminals, simply
      set pending_signals to 1 and return.  All hooks changed to not
      worry about whether input is blocked.
      (process_pending_signals): Clear pending_signals before processing
      them, in case a signal comes in while we're processing.
      By convention callers now test pending_signals before calling us.
      (UNBLOCK_INPUT_TO, unblock_input, totally_unblock_input):
      New functions, to support changes to blockinput.h.
      (handle_input_available_signal): Now extern.
      (reinvoke_input_signal): Remove.  All uses replaced by
      handle_async_input.
      (quit_count): Now volatile, since a signal handler uses it.
      (handle_interrupt): Now takes bool IN_SIGNAL_HANDLER as arg.  All
      callers changed.  Block SIGINT only if not already blocked.
      Clear sigmask reliably, even if Fsignal returns, which it can.
      Omit unnecessary accesses to volatile var.
      (quit_throw_to_read_char): No need to restore sigmask.
      * src/keyboard.c (gobble_input, handle_user_signal):
      * src/process.c (wait_reading_process_output):
      Call signal-handling code rather than killing ourselves.
      * src/lisp.h: Include <float.h>, for...
      (IEEE_FLOATING_POINT): New macro, moved here to avoid duplication.
      (pending_signals): Now volatile.
      (syms_of_data): Now const if IEEE floating point.
      (handle_input_available_signal) [USABLE_SIGIO]:
      (terminate_due_to_signal, record_child_status_change): New decls.
      * src/process.c (create_process): Avoid disaster if memory is exhausted
      while we're processing a vfork, by tightening the critical section
      around the vfork.
      (send_process_frame, process_sent_to, handle_pipe_signal)
      (deliver_pipe_signal): Remove.  No longer needed, as Emacs now
      ignores SIGPIPE.
      (send_process): No need for setjmp/longjmp any more, since the
      SIGPIPE stuff is now gone.  Instead, report an error if errno
      is EPIPE.
      (record_child_status_change): Now extern.  PID and W are now args.
      Return void, not bool.  All callers changed.
      * src/sysdep.c (wait_debugging) [(BSD_SYSTEM || HPUX) && !defined (__GNU__)]:
      Remove.  All uses removed.  This bug should be fixed now in a
      different way.
      (wait_for_termination_1): Use waitpid rather than sigsuspend,
      and record the child status change directly.  This avoids the
      need to futz with the signal mask.
      (process_fatal_action): Move here from emacs.c.
      (emacs_sigaction_flags): New function, containing
      much of what used to be in emacs_sigaction_init.
      (emacs_sigaction_init): Use it.  Block nonfatal system signals that are
      caught by emacs, to make races less likely.
      (deliver_process_signal): Rename from handle_on_main_thread.
      All uses changed.
      (BACKTRACE_LIMIT_MAX): Now at top level.
      (thread_backtrace_buffer, threadback_backtrace_pointers):
      New static vars.
      (deliver_thread_signal, deliver_fatal_thread_signal):
      New functions, for more-accurate delivery of thread-specific signals.
      (handle_fatal_signal, deliver_fatal_signal): Move here from emacs.c.
      (deliver_arith_signal): Handle in this thread, not
      in the main thread, since it's triggered by this thread.
      (maybe_fatal_sig): New function.
      (init_signals): New arg DUMPING so that we can be more accurate
      about whether we're dumping.  Caller changed.
      Treat thread-specific signals differently from process-general signals.
      Block all signals while handling fatal error; that's safer.
      xsignal from SIGFPE only on non-IEEE hosts, treating it as fatal
      on IEEE hosts.
      When batch, ignore SIGHUP, SIGINT, SIGTERM if they were already ignored.
      Ignore SIGPIPE unless batch.
      (emacs_backtrace): Output backtrace for the appropriate thread,
      which is not necessarily the main thread.
      * src/syssignal.h: Include <stdbool.h>.
      (emacs_raise): New macro.
      * src/xterm.c (x_connection_signal): Remove; no longer needed
      now that we use sigaction.
      (x_connection_closed): No need to mess with sigmask now.
      (x_initialize): No need to reset SIGPIPE handler here, since
      init_signals does this for us now.
      
      Fixes: debbugs:12471
      4d7e6e51
  29. 22 Sep, 2012 2 commits
  30. 17 Sep, 2012 1 commit