1. 15 Dec, 2014 1 commit
  2. 07 Nov, 2014 3 commits
  3. 23 Sep, 2014 3 commits
    • Paul Eggert's avatar
      * lisp.h (lispstpcpy): Rename from lispstrcpy, and act like stpcpy. · 97914756
      Paul Eggert authored
      All callers changed.
      * xterm.c (x_term_init): Use new functionality to avoid two needs
      to compute a string length.
      97914756
    • Dmitry Antipov's avatar
      Use known length of a Lisp string to copy it faster. · 59e10fbd
      Dmitry Antipov authored
      * lisp.h (lispstrcpy): New function.  Add comment.
      * callproc.c (child_setup):
      * dbusbind.c (xd_append_arg):
      * doc.c (get_doc_string):
      * font.c (Ffont_xlfd_name):
      * frame.c (xrdb_get_resource):
      * process.c (Fmake_network_process, network_interface_info):
      * w32fns.c (Fx_open_connection):
      * w32proc.c (sys_spawnve):
      * xfns.c (select_visual):
      * xfont.c (xfont_list):
      * xsmfns.c (x_session_initialize):
      * xterm.c (x_term_init): Use it.
      59e10fbd
    • Paul Eggert's avatar
      Fix SAFE_ALLOCA to not exhaust the stack when in a loop. · cb8e2bfb
      Paul Eggert authored
      Problem reported by Dmietry Antipov in thread leading to:
      http://lists.gnu.org/archive/html/emacs-devel/2014-09/msg00713.html
      This patch fixes only SAFE_ALLOCA, SAFE_NALLOCA, and SAFE_ALLOCA_LISP;
      the experimental local_* macros enabled by USE_LOCAL_ALLOCATORS
      remain unfixed.
      * callproc.c (call_process): Save and restore sa_avail.
      * lisp.h (USE_SAFE_ALLOCA): Define sa_avail.
      (AVAIL_ALLOCA): New macro.
      (SAFE_ALLOCA, SAFE_NALLOCA, SAFE_ALLOCA_LISP):
      Use it, and check against sa_avail rather than MAX_ALLOCA.
      cb8e2bfb
  4. 14 Sep, 2014 1 commit
  5. 07 Sep, 2014 3 commits
    • Paul Eggert's avatar
      * callproc.c (exec_failed) [DOS_NT]: Define a dummy. · d5e25ad1
      Paul Eggert authored
      All callers simplified.  Add a comment about exec_failed, vfork,
      and alloca.
      d5e25ad1
    • Eli Zaretskii's avatar
      Fix the MS-Windows build broken by SAFE_ALLOCA changes. · 970d21e8
      Eli Zaretskii authored
       src/callproc.c (child_setup) [WINDOWSNT]: Don't call exec_failed if
       'alloca' gets passed arguments larger than MAX_ALLOCA.
       src/font.c (MAX): Define if not defined elsewhere.
      970d21e8
    • Paul Eggert's avatar
      Use SAFE_ALLOCA etc. to avoid unbounded stack allocation. · b3bf18b3
      Paul Eggert authored
      This follows up on the recent thread in emacs-devel on alloca; see:
      http://lists.gnu.org/archive/html/emacs-devel/2014-09/msg00042.html
      This patch also cleans up alloca-related glitches noted while
      examining the code looking for unbounded alloca.
      * alloc.c (listn):
      * callproc.c (init_callproc):
      Rewrite to avoid need for alloca.
      * buffer.c (mouse_face_overlay_overlaps)
      (report_overlay_modification):
      * buffer.h (GET_OVERLAYS_AT):
      * coding.c (make_subsidiaries):
      * doc.c (Fsnarf_documentation):
      * editfns.c (Fuser_full_name):
      * fileio.c (Ffile_name_directory, Fexpand_file_name)
      (search_embedded_absfilename, Fsubstitute_in_file_name):
      * fns.c (Fmake_hash_table):
      * font.c (font_vconcat_entity_vectors, font_update_drivers):
      * fontset.c (fontset_pattern_regexp, Ffontset_info):
      * frame.c (Fmake_terminal_frame, x_set_frame_parameters)
      (xrdb_get_resource, x_get_resource_string):
      * ftfont.c (ftfont_get_charset, ftfont_check_otf, ftfont_drive_otf):
      * ftxfont.c (ftxfont_draw):
      * image.c (xbm_load, xpm_load, jpeg_load_body):
      * keyboard.c (echo_add_key, menu_bar_items, tool_bar_items):
      * keymap.c (Fdescribe_buffer_bindings, describe_map):
      * lread.c (openp):
      * menu.c (digest_single_submenu, find_and_call_menu_selection)
      (find_and_return_menu_selection):
      * print.c (PRINTFINISH):
      * process.c (Fformat_network_address):
      * scroll.c (do_scrolling, do_direct_scrolling, scrolling_1):
      * search.c (search_buffer, Fmatch_data, Fregexp_quote):
      * sound.c (wav_play, au_play):
      * syntax.c (skip_chars):
      * term.c (tty_menu_activate, tty_menu_show):
      * textprop.c (get_char_property_and_overlay):
      * window.c (Fset_window_configuration):
      * xdisp.c (safe__call, next_overlay_change, vmessage)
      (compute_overhangs_and_x, draw_glyphs, note_mouse_highlight):
      * xfaces.c (face_at_buffer_position):
      * xmenu.c (x_menu_show):
      Use SAFE_ALLOCA etc. instead of plain alloca, since the
      allocation size isn't bounded.
      * callint.c (Fcall_interactively): Redo memory_full check
      so that it can be done at compile-time on some platforms.
      * coding.c (MAX_LOOKUP_MAX): New constant.
      (get_translation_table): Use it.
      * callproc.c (call_process): Use SAFE_NALLOCA instead of
      SAFE_ALLOCA, to catch integer overflows on size calculation.
      (exec_failed) [!DOS_NT]: New function.
      (child_setup) [!DOS_NT]: Use it.
      * editfns.c (Ftranspose_regions):
      Hoist USE_SAFE_ALLOC + SAFE_FREE out of 'if'.
      * editfns.c (check_translation):
      Allocate larger buffers on the heap.
      * eval.c (internal_lisp_condition_case):
      Check for MAX_ALLOCA overflow.
      * fns.c (sort_vector): Use SAFE_ALLOCA_LISP rather than Fmake_vector.
      (Fbase64_encode_region, Fbase64_decode_region):
      Avoid unnecessary calls to SAFE_FREE before 'error'.
      * buffer.c (mouse_face_overlay_overlaps):
      * editfns.c (Fget_pos_property, check_translation):
      * eval.c (Ffuncall):
      * font.c (font_unparse_xlfd, font_find_for_lface):
      * ftfont.c (ftfont_drive_otf):
      * keyboard.c (echo_add_key, read_decoded_event_from_main_queue)
      (menu_bar_items, tool_bar_items):
      * sound.c (Fplay_sound_internal):
      * xdisp.c (load_overlay_strings, dump_glyph_row):
      Use an ordinary auto buffer rather than alloca, since the
      allocation size is fixed and small.
      * ftfont.c: Include <c-strcase.h>.
      (matching_prefix): New function.
      (get_adstyle_property): Use it, to avoid need for alloca.
      * keyboard.c (echo_add_key):
      * keymap.c (describe_map): Use ptrdiff_t, not int.
      * keyboard.c (echo_add_key): Prefer sizeof to strlen.
      * keymap.c (Fdescribe_buffer_bindings): Use SBYTES, not SCHARS,
      when counting bytes.
      * lisp.h (xlispstrdupa): Remove, replacing with ...
      (SAFE_ALLOCA_STRING): ... new macro with different API.
      This fixes a portability problem, namely, alloca result
      passed to another function.  All uses changed.
      (SAFE_ALLOCA, SAFE_ALLOCA_LISP): Check for MAX_ALLOCA,
      not MAX_ALLOCA - 1.
      * regex.c (REGEX_USE_SAFE_ALLOCA, REGEX_SAFE_FREE)
      (REGEX_ALLOCATE): New macros.
      (REGEX_REALLOCATE, REGEX_ALLOCATE_STACK, REGEX_REALLOCATE_STACK)
      (REGEX_FREE_STACK, FREE_VARIABLES, re_match_2_internal):
      Use them.
      * xdisp.c (message3): Use SAFE_ALLOCA_STRING rather than doing it
      by hand.
      (decode_mode_spec_coding): Store directly into buf rather than
      into an alloca temporary and copying the temporary to the buf.
      
      Fixes: debbugs:18410
      b3bf18b3
  6. 02 Sep, 2014 1 commit
  7. 01 Sep, 2014 1 commit
    • Dmitry Antipov's avatar
      Avoid extra calls to strlen in filesystem I/O routines. · 50e9e580
      Dmitry Antipov authored
      * fileio.c (Fexpand_file_name): Avoid calls to strlen if
      the length of 'newdir' is known or may be precalculated.
      (file_accessible_directory_p): Prefer to pass Lisp_Object,
      not 'char *', and so use precalculated length.
      (Ffile_accessible_directory_p):
      * callproc.c (encode_current_directory, init_callproc):
      * charset.c (init_charset):
      * lread.c (load_path_check, load_path_default): Adjust users.
      * lisp.h (file_accessible_directory_p): Tweak prototype.
      50e9e580
  8. 14 Jul, 2014 1 commit
    • Paul Eggert's avatar
      Use binary-io module, O_BINARY, and "b" flag. · ba1ed52f
      Paul Eggert authored
      * admin/merge-gnulib (GNULIB_MODULES): Add binary-io.  It was already
      present implicitly; this just makes the dependence explicit.
      * lib-src/etags.c, lib-src/hexl.c, lib-src/make-docfile.c:
      Include binary-io.h instead of fcntl.h and/or io.h.
      (main): Use set_binary_mode or SET_BINARY
      in place of handcrafted code.
      * lib-src/etags.c (main) [DOS_NT]:
      * lib-src/movemail.c (main) [WINDOWSNT]:
      Don't mess with _fmode.
      * lib-src/etags.c (main, process_file_name, analyse_regex):
      Use fopen/popen's "b" flag instead.
      * lib-src/movemail.c (main, popmail): Use open/lk_open/mkostemp's O_BINARY
      instead.
      * src/callproc.c (create_temp_file): Use mkostemp's O_BINARY flag.
      * src/emacs.c [MSDOS]:
      * src/emacs.c (main) [DOS_NT]: Don't mess with _fmode.
      (main) [MSDOS]: Use SET_BINARY instead of setmode.
      * src/minibuf.c: Include binary-io.h instead of fcntl.h.
      (read_minibuf_noninteractive):
      Use set_binary_mode instead of handcrafted code.
      Don't call emacs_set_tty if emacs_get_tty faile...
      ba1ed52f
  9. 02 Jun, 2014 1 commit
  10. 01 Jun, 2014 1 commit
    • Paul Eggert's avatar
      Port signal-handling to DragonFly BSD. · 5c2b9423
      Paul Eggert authored
      * callproc.c, sysdep.c (block_child_signal, unblock_child_signal):
      Move implementations from callproc.c to sysdep.c.
      * process.h, syssignal.h (block_child_signal, unblock_child_signal):
      Move declaratations from process.h to syssignal.h.
      
      Fixes: debbugs:17646
      5c2b9423
  11. 30 May, 2014 1 commit
    • Paul Eggert's avatar
      Don't let SIGINT handling block SIGCHLD indefinitely. · 8cf1e6e6
      Paul Eggert authored
      * atimer.c (block_atimers):
      * callproc.c (block_child_signal): Block SIGINT too;
      otherwise, its handler might now unblock signals that it shouldn't.
      * keyboard.c (read_char): Clear signal mask, since we may
      be in a SIGINT handler, and many signals may be masked.
      * keyboard.c (handle_interrupt):
      * sysdep.c (handle_arith_signal):
      Clear signal mask instead of just unblocking the signal that
      was received, since several signals may be blocked at this point.
      
      Fixes: debbugs:17561
      8cf1e6e6
  12. 16 Apr, 2014 1 commit
    • Eli Zaretskii's avatar
      Fix the MSDOS build. · bf6b4923
      Eli Zaretskii authored
       src/unexcoff.c [MSDOS]: Include libc/atexit.h.
       (copy_text_and_data): Zero out the atexit chain pointer before
       dumping Emacs.
       src/termhooks.h (encode_terminal_code): Update prototype.
       src/term.c (encode_terminal_code) [DOS_NT]: Make it externally
       visible for all DOS_NT ports, not just WINDOWSNT.
       (syms_of_term) [!MSDOS]: Don't define 'tty-menu-*' symbols on MSDOS.
       src/sysdep.c (emacs_sigaction_init, init_signals): Don't use SIGCHLD
       unless it is defined.
       (emacs_pipe) [MSDOS]: Redirect to 'pipe'.
       src/process.c (close_on_exec, accept4, process_socket): Move into
       the "ifdef subprocesses" part.
       (catch_child_signal): Condition by "ifdef subprocesses".
       (syms_of_process) <Qinternal_default_process_sentinel>
       <Qinternal_default_process_filter>: Condition by "ifdef subprocesses".
       src/msdos.h: Add prototypes for new functions.
       (EINPROGRESS): Define.
       (O_CLOEXEC): Define to zero.
       src/msdos.c (check_window_system): Remove unnecessary an
       incompatible duplicate function.
       (sys_opendir, readlinkat, faccessat, fstatat, unsetenv): New
       functions in support of new functionality.
       src/menu.c (single_menu_item): Add visual indication  of submenu
       also for menus on MSDOS frames.
       (Fx_popup_menu) [!MSDOS]: Do not call tty_menu_show on MSDOS.
       src/lisp.h (CHECK_PROCESS) [!subprocesses]: Do not define
       when async subprocesses aren't supported.
       src/font.h (FONT_WIDTH) [MSDOS]: MSDOS-specific definition.
       src/emacs.c (close_output_streams): Zero out errno before calling
       close_stream.
       src/dired.c [MSDOS]: Include msdos.h.
       src/conf_post.h (opendir) [MSDOS]: Redirect to sys_opendir.
       (DATA_START) [MSDOS]: Define.
       (SYSTEM_PURESIZE_EXTRA) [MSDOS]: Enlarge by 25K.
       src/callproc.c (block_child_signal, unblock_child_signal) [MSDOS]:
       Ifdef away for MSDOS.
       (record_kill_process) [MSDOS]: Ifdef away the entire body for MSDOS.
       (call_process_cleanup) [MSDOS]: Ifdef away portions not relevant
       for MSDOS.
       (call_process) [MSDOS]: Fix call sequence of dostounix_filename.
       Use temporary file template that is compatible with mkostemp.
       Move vfork-related portions under #ifndef MSDOS.
       (syms_of_callproc): Unify templates of MSDOS and WINDOWSNT.
      
       lisp/term/pc-win.el (x-list-fonts, x-get-selection-value): Provide
       doc strings, as required by snarf-documentation.
      
       msdos/sedlisp.inp:
       msdos/sedlibmk.inp:
       msdos/sedleim.inp:
       msdos/sed3v2.inp:
       msdos/sed2v2.inp:
       msdos/sed1v2.inp: Update Sed scripts for Emacs 24.4.
       msdos/inttypes.h: Add PRIdMAX.
       msdos/INSTALL: Update for Emacs 24.4.
       msdos/sedadmin.inp: New file.
      bf6b4923
  13. 25 Mar, 2014 1 commit
    • Paul Eggert's avatar
      Handle sigmask better with nested signal handlers. · 1e952f0a
      Paul Eggert authored
      * atimer.c (sigmask_atimers): Remove.
      Remaining use rewritten to use body of this function.
      * atimer.c (block_atimers, unblock_atimers):
      * callproc.c (block_child_signal, unblock_child_signal):
      * sysdep.c (block_tty_out_signal, unblock_tty_out_signal):
      New arg OLDSET.  All callers changed.
      * atimer.c (block_atimers, unblock_atimers):
      * callproc.c (block_child_signal, unblock_child_signal):
      * keyboard.c (handle_interrupt):
      * sound.c (vox_configure, vox_close):
      Restore the old signal mask rather than unilaterally clearing bits
      from the mask, in case a handler is running within another
      handler.  All callers changed.
      * lisp.h, process.c, process.h, term.c:
      Adjust decls and callers to match new API.
      * sysdep.c (emacs_sigaction_init): Don't worry about masking SIGFPE;
      signal handlers aren't supposed to use floating point anyway.
      (handle_arith_signal): Unblock just SIGFPE rather than clearing mask.
      
      Fixes: debbugs:15561
      1e952f0a
  14. 22 Mar, 2014 1 commit
    • Glenn Morris's avatar
      Make some files in etc obsolete · 00156f95
      Glenn Morris authored
      These are old copies of online information that is not Emacs-specific.
      
      * etc/CENSORSHIP, etc/GNU, etc/LINUX-GNU, etc/THE-GNU-PROJECT, etc/WHY-FREE:
      Replace contents with pointers to www.gnu.org or emacs.info, mark obsolete.
      
      * src/callproc.c (init_callproc): In etc, look for NEWS rather than GNU.
      
      * lisp/startup.el (fancy-startup-text):
      * lisp/help.el (describe-gnu-project): Visit online info about GNU project.
      
      * doc/emacs/help.texi (Help Files): Update C-h g description.
      
      * doc/misc/efaq.texi (Informational files for Emacs): Do not mention etc/GNU.
      
      * admin/notes/copyright: Remove references to these files.
      
      * etc/MACHINES, etc/NEWS.19: Replace references to these files.
      00156f95
  15. 30 Jan, 2014 1 commit
  16. 01 Jan, 2014 1 commit
  17. 27 Dec, 2013 1 commit
    • Jarek Czekalski's avatar
      Shell completion for filenames from current directory, related docs. · fdadeb49
      Jarek Czekalski authored
      	* lisp/shell.el  Shell completion now matches executable filenames from
      	the current buffer's directory, on systems in which this behaviour
      	is the default (windows-nt, ms-dos).
      	* src/callproc.c (Vexec_path): Document that exec-directory is in it.
      	* doc/emacs/mini.texi (Completion Options): Add a link to Shell Options.
      	* doc/emacs/misc.texi (Shell Mode): Move documentation of
      	shell-completion-fignore from Shell Mode to Shell Options.
      
      Fixes: debbugs:15461
      fdadeb49
  18. 18 Dec, 2013 2 commits
    • Paul Eggert's avatar
      Minor fixes for recent openp changes. · 518c40a2
      Paul Eggert authored
      * lisp.h (GCPRO7): New macro.
      * lread.c (openp): Use bool for boolean; all callers changed.
      Protect save_string from GC.  Don't assume that file descriptors
      are nonzero.  Redo save_mtime comparison to avoid bogus GCC
      warning about uninitialized variable.
      518c40a2
    • Glenn Morris's avatar
      Add load-prefer-newer option, to load .el if newer than .elc · 1f41ee56
      Glenn Morris authored
      * src/lread.c (Fload): Pass load_prefer_newer to openp.
      Don't bother checking mtime if openp already did it.
      (openp): Add `newer' argument, to check all suffixes
      and find the newest file.
      (syms_of_lread) <load_prefer_newer>: New option. 
      
      * src/callproc.c (call_process):
      * src/charset.c (load_charset_map_from_file):
      * src/emacs.c (init_cmdargs):
      * src/image.c (x_create_bitmap_from_file, x_find_image_file):
      * src/lisp.h (openp):
      * lread.c (Flocate_file_internal):
      * src/process.c (Fformat_network_address):
      * src/sound.c (Fplay_sound_internal):
      * src/w32.c (check_windows_init_file):
      * src/w32proc.c (sys_spawnve): Update for new arg spec of openp.
      
      * lisp/Makefile.in (BYTE_COMPILE_FLAGS): Set load-prefer-newer to t.
      
      * etc/NEWS: Mention this.
      
      Fixes: debbugs:2061
      1f41ee56
  19. 07 Dec, 2013 1 commit
  20. 26 Nov, 2013 1 commit
    • Glenn Morris's avatar
      Preload leim-list.el · 624780f0
      Glenn Morris authored
      * Makefile.in (abs_builddir): New, set by configure.
      (buildlisppath): Add leim/.
      (epaths-force-w32): Set BLD.
      
      * lisp/loadup.el: Load leim-list.el when found.
      
      * lisp/startup.el (normal-top-level): Skip re-loading leim/leim-list.el.
      
      * nt/epaths.nt (PATH_DUMPLOADSEARCH): Add leim/.
      
      * src/callproc.c (init_callproc): Don't assume PATH_DUMPLOADSEARCH
      is a single directory.
      
      * src/epaths.in (PATH_DUMPLOADSEARCH): Add leim/.
      
      Fixes: debbugs:4789
      624780f0
  21. 23 Nov, 2013 1 commit
    • Glenn Morris's avatar
      Empty elements in EMACSLOADPATH now stand for the default · 17e0445b
      Glenn Morris authored
      * src/lread.c (load_path_check): Take path to check as argument.
      (load_path_default): New, split from init_lread.
      (init_lread): Move calc of default load-path to load_path_default.
      Empty elements in EMACSLOADPATH now stand for the default.
      (load-path): Doc fix.
      
      * src/emacs.c (decode_env_path): Add option to treat empty elements
      as nil rather than ".".
      
      * src/callproc.c (init_callproc_1, init_callproc):
      * src/image.c (Vx_bitmap_file_path):
      * src/lisp.h (decode_env_path):
      * lread.c (Vsource_directory):
      Update for new argument spec of decode_env_path.
      
      * leim/Makefile.in (RUN_EMACS): Empty EMACSLOADPATH rather than unsetting.
      
      * lisp/Makefile.in (emacs): Empty EMACSLOADPATH rather than unsetting.
      
      * test/automated/Makefile.in (emacs):
      Empty EMACSLOADPATH rather than unsetting.
      
      * doc/emacs/cmdargs.texi (General Variables):
      Empty elements in EMACSLOADPATH now mean the default load-path.
      
      * doc/lispref/loading.texi (Library Search):
      Empty elements in EMACSLOADPATH now mean the default load-path.
      
      * etc/NEWS: Mention this.
      
      Fixes: debbugs:12100
      17e0445b
  22. 05 Nov, 2013 2 commits
  23. 04 Nov, 2013 1 commit
    • Eli Zaretskii's avatar
      Fix bug #15260 with building and installing Emacs in non-ASCII directories. · d0065ff1
      Eli Zaretskii authored
       src/xdisp.c (message3_nolog, message_with_string): Encode the string
       before writing it to the terminal in a non-interactive session.
       src/lread.c (openp): If both FILENAME and SUFFIX are unibyte, make
       sure we concatenate them into a unibyte string.
       src/fileio.c (make_temp_name): Encode PREFIX, and decode the
       resulting temporary name before returning it to the caller.
       (Fexpand_file_name): If NAME is pure-ASCII and DEFAULT_DIRECTORY
       is a unibyte string, convert NAME to a unibyte string to ensure
       that the result is also a unibyte string.
       src/emacs.c (init_cmdargs): Use build_unibyte_string to make sure we
       create unibyte strings from default paths and directory/file
       names.
       src/coding.h (ENCODE_FILE): Do not attempt to encode a unibyte
       string.
       src/callproc.c (init_callproc): Use build_unibyte_string to make
       sure we create unibyte strings from default paths and
       directory/file names.
       src/buffer.c (init_buffer): Don't store default-directory of
       *scratch* in multibyte form.  The original problem which led to
       that is described in
       http://lists.gnu.org/archive/html/emacs-pretest-bug/2004-11/msg00532.html,
       but it was solved long ago.
      
       lisp/startup.el (normal-top-level): Move setting eol-mnemonic-unix,
       eol-mnemonic-mac, eol-mnemonic-dos, and also setup of the locale
       environment and decoding all of the default-directory's to here
       from command-line.
       (command-line): Decode also argv[0].
       lisp/loadup.el: Error out if default-directory is a multibyte string
       when we are dumping.
       lisp/Makefile.in (emacs): Don't set LC_ALL=C.
      
       leim/Makefile.in (RUN_EMACS): Don't set LC_ALL=C.
      
       configure.ac: Don't disallow builds in non-ASCII directories.
      d0065ff1
  24. 23 Aug, 2013 1 commit
    • Paul Eggert's avatar
      Don't let very long directory names overrun the stack. · c365c355
      Paul Eggert authored
      Fix some related minor problems involving "//", vfork.
      * callproc.c (encode_current_directory): New function.
      (call_process): Don't append "/"; not needed.
      * fileio.c (file_name_as_directory_slop): New constant.
      (file_name_as_directory): Allow SRC to be longer than SRCLEN;
      this can save the caller having to alloca.
      (Ffile_name_as_directory, Fdirectory_file_name, Fexpand_file_name):
      Use SAFE_ALLOCA, not alloca.
      (directory_file_name, Fexpand_file_name): Leave leading "//"
      alone, since it can be special even on POSIX platforms.
      * callproc.c (call_process):
      * process.c (Fformat_network_address):
      * sysdep.c (sys_subshell):
      Use encode_current_directory rather than rolling our own.
      (create_process): No need to encode directory; caller does that now.
      * process.h (encode_current_directory): New decl.
      * sysdep.c (sys_subshell): Work even if vfork trashes saved_handlers.
      Rework to avoid 'goto xyzzy;'.
      c365c355
  25. 21 Aug, 2013 1 commit
    • Paul Eggert's avatar
      * callproc.c: Fix race that killed background processes. · 4a88129a
      Paul Eggert authored
      (call_process): New arg TEMPFILE_INDEX.  Callers changed.
      Record deleted process-id in critical section, not afterwards.
      Don't mistakenly kill process created by a call-process invocation
      that discards output and does not wait.
      
      Fixes: debbugs:15144
      4a88129a
  26. 12 Aug, 2013 1 commit
    • Paul Eggert's avatar
      Fix some fd issues when running subprocesses. · 94fcd171
      Paul Eggert authored
      Fix bugs that can leak files or file descriptors on errors.
      Don't unlink open temp files, as that's hard for users to diagnose
      when things go awry (e.g., temp disk exhausted).
      Don't bother to lock temp files.  Check for invalid recursion.
      * callproc.c (synch_process_fd): Remove.  All uses removed.
      (synch_process_tempfile): New var or macro.
      (CALLPROC_STDOUT, CALLPROC_STDERR, CALLPROC_PIPEREAD, CALLPROC_FDS):
      New constants.
      (record_kill_process): New arg, the temp name.  All callers changed.
      (delete_temp_file): Now just a simple wrapper around unlink.
      (call_process_kill): New arg, the call_process_fd array.
      Close them all.  Clear synch_process_pid.  Remove the temp file,
      or arrange for it to be removed.
      (call_process_cleanup) [MSDOS]: Arg no longer contains file name;
      that's been moved to synch_process_tempfile.  Caller changed.
      Do not remove the tempfile; that's now call_process_kill's
      responsibility.
      (call_process_cleanup) [!MSDOS]: Do not record unwind-protect for
      call_process_kill; the caller now does that.
      (call_process_cleanup): Do not close the process fd; that's now
      call_process_kill's responsibility.
      (Fcall_process): Implement via new function call_process, which
      has most of the old body of Fcall_process, but with a different API.
      (call_process): New function that does not open or close filefd if
      it is nonnegative.  Record which fds need to be closed, and let
      call_process_kill close (and remove the tempfile, on MSDOS) on error.
      Signal an error if invoked recursively (could be done via a hook).
      Simplify creation of the tempfile in the MSDOS case.
      Don't create the output file until after checking for the executable.
      Report any failure to open /dev/null.
      Don't open /dev/null for writing twice; once is enough.
      Don't create pipe if all output is being discarded or sent to file.
      Don't worry about setting up the coding system or reading from the
      pipe if all output is being discarded.
      Hoist fd_error local into top level, to lessen block nesting.
      Don't record deleted pid here; now done by Fcall_process_region.
      (Fcall_process) [MSDOS]: Report mktemp failure immediately,
      and note its success in synch_process_tempfile.
      Do not leak resources when child_setup fails.
      (Fcall_process) [!MSDOS && !WINDOWSNT]: Remove duplicate assignment
      to child_errno.  Remove unnecessary close of fd0; it's close-on-exec.
      (create_temp_file): Now returns open fd, with an additional
      Lisp_Object * argument to return the name.  All callers changed.
      Do not close the file; rewind it instead, and leave it open for
      the caller.  Do not lock the temp file.  Unwind-protect the file
      and the file-descriptor.
      (Fcall_process_region): If the input is /dev/null, unwind-protect it.
      If an asynchrounous process, record it here, not in call_process.
      (syms_of_callproc) [MSDOS]: Initialize synch_process_tempfile.
      * eval.c (set_unwind_protect): New function.
      * fileio.c (write_region): New function, generalized from the
      old Fwrite_region.  Do not lock temp files.
      (Fwrite_region): Use it.
      * lisp.h (set_unwind_protect, write_region): New decls.
      * process.c: Include <verify.h>.
      (make_process): Mark fds as initially closed.
      (deleted_pid_list): Now a list of pid-filename pairs.
      All uses changed.
      (close_process_fd): New function.
      (SUBPROCESS_STDIN, WRITE_TO_SUBPROCESS, READ_FROM_SUBPROCESS)
      (SUBPROCESS_STDOUT, READ_FROM_EXEC_MONITOR, EXEC_MONITOR_OUTPUT):
      New constants.  Verify that their number matches PROCESS_OPEN_FDS.
      (create_process, create_pty, Fmake_serial_process)
      (server_accept_connection): Record which fds need to be closed,
      and let deactivate_process close them.
      (Fmake_network_process): Do not discard the unwind-protect
      until it's safe to do so.
      (deactivate_process): Close the fds opened by create_process etc.
      (Fprocess_send_eof): Adjust to new way of recording open fds.
      Report an error if /dev/null can't be opened, instead of aborting.
      * process.h (PROCESS_OPEN_FDS): New constant.
      (struct Lisp_Process): New member open_fds.
      (record_kill_process, record_deleted_pid): Adjust signatures.
      (record_deleted_pid): Move decl here ...
      * syswait.h (record_deleted_pid): ... from here.
      
      Fixes: debbugs:15035
      94fcd171
  27. 04 Aug, 2013 1 commit
    • Paul Eggert's avatar
      Fix some minor races in hosts lacking mkostemp. · e0fdb694
      Paul Eggert authored
      Gnulib's emulation of mkostemp doesn't have races that Emacs's does.
      * configure.ac (mkostemp): Remove check for this function;
      gnulib does the check now.
      (mkstemp): Remove check for this no-longer-used function.
      * lib/mkostemp.c, lib/secure_getenv.c, lib/tempname.c, lib/tempname.h:
      * m4/mkostemp.m4, m4/secure_getenv.m4, m4/tempname.m4:
      New files, copied from Gnulib.
      * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
      * admin/merge-gnulib (GNULIB_MODULES): Add mkostemp.
      * lib-src/movemail.c (main):
      * lib-src/update-game-score.c (write_scores):
      Use mkostemp (which now works on all platforms, due to changes
      in the portability layer) rather than mktemp (which has a race)
      or mkstemp (which we no longer bother with).
      * src/callproc.c (create_temp_file):
      * src/filelock.c (create_lock_file):
      Assume mkostemp, since it's now provided by Gnulib.
      
      Fixes: debbugs:15015
      e0fdb694
  28. 30 Jul, 2013 1 commit
  29. 23 Jul, 2013 1 commit
  30. 21 Jul, 2013 1 commit
    • Paul Eggert's avatar
      Avoid vfork-related deadlock more cleanly. · ee010797
      Paul Eggert authored
      * callproc.c (child_setup): When the child's exec fails, output
      the program name, as that's more useful.  Use O_NONBLOCK to avoid
      deadlock.
      * process.c (create_process_1): Remove; no longer needed.
      (create_process): Remove timer hack; no longer needed, now that
      the child avoids deadlock.
      ee010797
  31. 17 Jul, 2013 1 commit
    • Paul Eggert's avatar
      A few more minor file errno-reporting bugs. · b648c163
      Paul Eggert authored
      * callproc.c (Fcall_process):
      * doc.c (Fsnarf_documentation):
      * fileio.c (Frename_file, Fadd_name_to_file, Fmake_symbolic_link):
      * process.c (set_socket_option):
      Don't let a constructor trash errno.
      * doc.c: Include <errno.h>.
      b648c163
  32. 16 Jul, 2013 1 commit
    • Paul Eggert's avatar
      Fix w32 bug with call-process-region. · 50a30cce
      Paul Eggert authored
      * callproc.c (Fcall_process_region): Pass nil, not "/dev/null",
      to Fcall_process when the input is empty.  This simplifies the
      code a bit.  It makes no difference on POSIXish platforms but
      apparently it fixes a bug on w32.
      
      Fixes: debbugs:14885
      50a30cce