aboutsummaryrefslogtreecommitdiffstats
path: root/src/callproc.c
Commit message (Collapse)AuthorAgeFilesLines
* delete_temp_file fixBT Templeton2015-04-191-3/+9
| | | | | * src/callproc.c (delete_temp_file_ptr): New function. (call_process_kill): Use it.
* use dynwind_begin and dynwind_endBT Templeton2015-04-181-7/+10
| | | | This patch was generated using Coccinelle.
* use dynwind_begin and dynwind_endBT Templeton2015-04-181-8/+10
| | | | | This commit only changes uses of `SPECPDL_INDEX' and `unbind_to' that could not be easily converted using Coccinelle.
* record_unwind_protect error handlingBT Templeton2015-04-181-42/+35
|
* SAFE_ALLOCA updatedBT Templeton2015-04-181-4/+0
| | | | | | | | | | * src/alloc.c (record_xmalloc): Remove. All uses changed. * src/lisp.h (SAFE_ALLOCA, SAFE_NALLOCA, SAFE_ALLOCA_LISP): Use normal allocation functions and don't explicitly free memory. Remove all references to variables defined by these macros. (USE_SAFE_ALLOCA, SAFE_FREE): Now no-ops.
* use guile-snarf for subr definitionBT Templeton2015-04-181-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/Makefile.in: Run guile-snarf on files that previously contained `defsubr' calls. * src/alloc.c (syms_of_alloc): * src/buffer.c (syms_of_buffer): * src/bytecode.c (syms_of_bytecode): * src/callint.c (syms_of_callint): * src/callproc.c (syms_of_callproc): * src/casefiddle.c (syms_of_casefiddle): * src/casetab.c (syms_of_casetab): * src/category.c (syms_of_category): * src/ccl.c (syms_of_ccl): * src/character.c (syms_of_character): * src/charset.c (syms_of_charset): * src/chartab.c (syms_of_chartab): * src/cmds.c (syms_of_cmds): * src/coding.c (syms_of_coding): * src/composite.c (syms_of_composite): * src/data.c (syms_of_data): * src/dbusbind.c (syms_of_dbusbind): * src/dired.c (syms_of_dired): * src/dispnew.c (syms_of_display): * src/doc.c (syms_of_doc): * src/dosfns.c (syms_of_dosfns): * src/editfns.c (syms_of_editfns): * src/emacs.c (syms_of_emacs): * src/eval.c (syms_of_eval): * src/fileio.c (syms_of_fileio): * src/filelock.c (syms_of_filelock): * src/floatfns.c (syms_of_floatfns): * src/fns.c (syms_of_fns): * src/font.c (syms_of_font): * src/fontset.c (syms_of_fontset): * src/frame.c (syms_of_frame): * src/fringe.c (syms_of_fringe): * src/gnutls.c (syms_of_gnutls): * src/image.c (syms_of_image): * src/indent.c (syms_of_indent): * src/insdel.c (syms_of_insdel): * src/keyboard.c (syms_of_keyboard): * src/keymap.c (syms_of_keymap): * src/lread.c (syms_of_lread): * src/macros.c (syms_of_macros): * src/marker.c (syms_of_marker): * src/menu.c (syms_of_menu): * src/minibuf.c (syms_of_minibuf): * src/msdos.c (syms_of_msdos): * src/nsfns.m (syms_of_nsfns): * src/nsmenu.m (syms_of_nsmenu): * src/nsselect.m (syms_of_nsselect): * src/print.c (syms_of_print): * src/process.c (syms_of_process): * src/search.c (syms_of_search): * src/sound.c (syms_of_sound): * src/syntax.c (syms_of_syntax): * src/term.c (syms_of_term): * src/terminal.c (syms_of_terminal): * src/textprop.c (syms_of_textprop): * src/undo.c (syms_of_undo): * src/w16select.c (syms_of_win16select): * src/w32console.c (syms_of_ntterm): * src/w32fns.c (syms_of_w32fns): * src/w32font.c (syms_of_w32font): * src/w32menu.c (syms_of_w32menu): * src/w32proc.c (syms_of_ntproc): * src/w32select.c (syms_of_w32select): * src/window.c (syms_of_window): * src/xdisp.c (syms_of_xdisp): * src/xfaces.c (syms_of_xfaces): * src/xfns.c (syms_of_xfns): * src/xmenu.c (syms_of_xmenu): * src/xml.c (syms_of_xml): * src/xselect.c (syms_of_xselect): * src/xsettings.c (syms_of_xsettings): * src/xsmfns.c (syms_of_xsmfns): Include guile-snarf files for subr definition.
* Merge from emacs-24; up to 2014-06-01T23:37:[email protected]Glenn Morris2014-06-071-2/+5
|\
| * * src/callproc.c (call_process): Don't check read-only if we don't insertStefan Monnier2014-06-021-2/+5
| | | | | | | | | | | | anything. Fixes: debbugs:17666
* | Port signal-handling to DragonFly BSD.Paul Eggert2014-06-011-24/+0
| | | | | | | | | | | | | | | | | | * 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
* | Don't let SIGINT handling block SIGCHLD indefinitely.Paul Eggert2014-05-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* | Merge from emacs-24; up to 2014-04-16T15:28:[email protected]Paul Eggert2014-04-161-7/+13
|\|
| * Fix the MSDOS build.Eli Zaretskii2014-04-161-7/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Handle sigmask better with nested signal handlers.Paul Eggert2014-03-251-9/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* | Make some files in etc obsoleteGlenn Morris2014-03-221-2/+2
|/ | | | | | | | | | | | | | | | | | | | 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.
* Don't ignore SIGPROF in subprocessesAndreas Schwab2014-01-301-0/+4
| | | | | * process.c (create_process): Reset SIGPROF handler in the child. * callproc.c (call_process): Likewise.
* Update copyright year to 2014 by running admin/update-copyright.Paul Eggert2014-01-011-1/+2
|
* Shell completion for filenames from current directory, related docs.Jarek Czekalski2013-12-271-1/+5
| | | | | | | | | | | | * 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
* Minor fixes for recent openp changes.Paul Eggert2013-12-181-1/+2
| | | | | | | | * 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.
* Add load-prefer-newer option, to load .el if newer than .elcGlenn Morris2013-12-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | * 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
* Preload leim-list.elGlenn Morris2013-11-251-4/+4
| | | | | | | | | | | | | | | | | | | * 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
* Empty elements in EMACSLOADPATH now stand for the defaultGlenn Morris2013-11-221-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* * src/xdisp.c (prepare_menu_bars): Mark static.Stefan Monnier2013-11-051-4/+0
| | | | | | * src/lisp.h (prepare_menu_bars): Don't declare. * src/xselect.c (x_handle_selection_clear): * src/callproc.c (call_process): Remove redundant call to prepare_menu_bars.
* Fix bug #15148 with garbled display in Dired when cache-long-scans is ON.Eli Zaretskii2013-11-051-0/+1
| | | | | | | src/callproc.c (call_process): Call prepare_to_modify_buffer before decoding text read from the sub-process, as the decoded stuff will be inserted into the buffer. This will invalidate the various caches maintained for the buffer.
* Fix bug #15260 with building and installing Emacs in non-ASCII directories.Eli Zaretskii2013-11-041-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Don't let very long directory names overrun the stack.Paul Eggert2013-08-231-22/+37
| | | | | | | | | | | | | | | | | | | | | 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;'.
* * callproc.c: Fix race that killed background processes.Paul Eggert2013-08-211-17/+28
| | | | | | | | | (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
* Fix some fd issues when running subprocesses.Paul Eggert2013-08-121-395/+367
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix some minor races in hosts lacking mkostemp.Paul Eggert2013-08-041-13/+1
| | | | | | | | | | | | | | | | | | | | | | 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
* Fix tempfile bug on platforms lacking mkostemp and mkstemp.Paul Eggert2013-07-301-2/+3
| | | | | | | * callproc.c (create_temp_file) [! (HAVE_MKOSTEMP || HAVE_MKSTEMP)]: Do not assume that emacs_close (INT_MAX) is a no-op. Fixes: debbugs:14986
* src/callproc.c (child_setup): Silence compiler warnings.Juanma Barranquero2013-07-231-2/+3
|
* Avoid vfork-related deadlock more cleanly.Paul Eggert2013-07-201-5/+9
| | | | | | | | | * 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.
* A few more minor file errno-reporting bugs.Paul Eggert2013-07-161-1/+5
| | | | | | | | | * 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>.
* Fix w32 bug with call-process-region.Paul Eggert2013-07-161-6/+4
| | | | | | | | | * 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
* New unwind-protect flavors to better type-check C callbacks.Paul Eggert2013-07-161-10/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This also lessens the need to write wrappers for callbacks, and the need for make_save_pointer. * alloca.c (free_save_value): * atimer.c (run_all_atimers): Now extern. * alloc.c (safe_alloca_unwind): * atimer.c (unwind_stop_other_atimers): * keyboard.c (cancel_hourglass_unwind) [HAVE_WINDOW_SYSTEM]: * menu.c (cleanup_popup_menu) [HAVE_NS]: * minibuf.c (choose_minibuf_frame_1): * process.c (make_serial_process_unwind): * xdisp.h (pop_message_unwind): * xselect.c (queue_selection_requests_unwind): Remove no-longer-needed wrapper. All uses replaced by the wrappee. * alloca.c (record_xmalloc): Prefer record_unwind_protect_ptr to record_unwind_protect with make_save_pointer. * alloca.c (Fgarbage_collect): Prefer record_unwind_protect_void to passing a dummy. * buffer.c (restore_buffer): * window.c (restore_window_configuration): * xfns.c, w32fns.c (do_unwind_create_frame) New wrapper. All record-unwind uses of wrappee changed. * buffer.c (set_buffer_if_live): * callproc.c (call_process_cleanup, delete_temp_file): * coding.c (code_conversion_restore): * dired.c (directory_files_internal_w32_unwind) [WINDOWSNT]: * editfns.c (save_excursion_restore) (subst_char_in_region_unwind, subst_char_in_region_unwind_1) (save_restriction_restore): * eval.c (restore_stack_limits, un_autoload): * fns.c (require_unwind): * keyboard.c (recursive_edit_unwind, tracking_off): * lread.c (record_load_unwind, load_warn_old_style_backquotes): * macros.c (pop_kbd_macro, restore_menu_items): * nsfns.m (unwind_create_frame): * print.c (print_unwind): * process.c (start_process_unwind): * search.c (unwind_set_match_data): * window.c (select_window_norecord, select_frame_norecord): * xdisp.c (unwind_with_echo_area_buffer, unwind_format_mode_line) (fast_set_selected_frame): * xfns.c, w32fns.c (unwind_create_tip_frame): Return void, not a dummy Lisp_Object. All uses changed. * buffer.h (set_buffer_if_live): Move decl here from lisp.h. * callproc.c (call_process_kill): * fileio.c (restore_point_unwind, decide_coding_unwind) (build_annotations_unwind): * insdel.c (Fcombine_after_change_execute_1): * keyboard.c (read_char_help_form_unwind): * menu.c (unuse_menu_items): * minibuf.c (run_exit_minibuf_hook, read_minibuf_unwind): * sound.c (sound_cleanup): * xdisp.c (unwind_redisplay): * xfns.c (clean_up_dialog): * xselect.c (x_selection_request_lisp_error, x_catch_errors_unwind): Accept no args and return void, instead of accepting and returning a dummy Lisp_Object. All uses changed. * cygw32.c (fchdir_unwind): * fileio.c (close_file_unwind): * keyboard.c (restore_kboard_configuration): * lread.c (readevalllop_1): * process.c (wait_reading_process_output_unwind): Accept int and return void, rather than accepting an Emacs integer and returning a dummy object. In some cases this fixes an unlikely bug when the corresponding int is outside Emacs integer range. All uses changed. * dired.c (directory_files_internal_unwind): * fileio.c (do_auto_save_unwind): * gtkutil.c (pop_down_dialog): * insdel.c (reset_var_on_error): * lread.c (load_unwind): * xfns.c (clean_up_file_dialog): * xmenu.c, nsmenu.m (pop_down_menu): * xmenu.c (cleanup_widget_value_tree): * xselect.c (wait_for_property_change_unwind): Accept pointer and return void, rather than accepting an Emacs save value encapsulating the pointer and returning a dummy object. All uses changed. * editfns.c (Fformat): Update the saved pointer directly via set_unwind_protect_ptr rather than indirectly via make_save_pointer. * eval.c (specpdl_func): Remove. All uses replaced by definiens. (unwind_body): New function. (record_unwind_protect): First arg is now a function returning void, not a dummy Lisp_Object. (record_unwind_protect_ptr, record_unwind_protect_int) (record_unwind_protect_void): New functions. (unbind_to): Support SPECPDL_UNWIND_PTR etc. * fileio.c (struct auto_save_unwind): New type. (do_auto_save_unwind): Use it. (do_auto_save_unwind_1): Remove; subsumed by new do_auto_save_unwind. * insdel.c (struct rvoe_arg): New type. (reset_var_on_error): Use it. * lisp.h (SPECPDL_UNWIND_PTR, SPECPDL_UNWIND_INT, SPECPDL_UNWIND_VOID): New constants. (specbinding_func): Remove; there are now several such functions. (union specbinding): New members unwind_ptr, unwind_int, unwind_void. (set_unwind_protect_ptr): New function. * xselect.c: Remove unnecessary forward decls, to simplify maintenance.
* * fileio.c (report_file_errno): Fix errno reporting bug.Paul Eggert2013-07-161-11/+8
| | | | | | | | If the file name is neither null nor a pair, package it up as a singleton list. All callers changed, both to this function and to report_file_error. This fixes a bug where the memory allocator invoked by list1 set errno so that the immediately following report_file_error reported the wrong errno value.
* Fix porting bug to older POSIXish platforms.Paul Eggert2013-07-161-1/+1
| | | | | | | | | * sysdep.c (emacs_pipe): New function, that implements pipe2 (fd, O_CLOEXEC) even on hosts that lack O_CLOEXEC. This should port better to CentOS 5 and to Mac OS X 10.6. All calls to pipe2 changed. Fixes: debbugs:14862
* Prefer list1 (X) to Fcons (X, Qnil) when building lists.Paul Eggert2013-07-151-9/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes the code easier to read and the executable a bit smaller. Do not replace all calls to Fcons that happen to create lists, just calls that are intended to create lists. For example, when creating an alist that maps FOO to nil, use list1 (Fcons (FOO, Qnil)) rather than list1 (list1 (FOO)) or Fcons (Fcons (FOO, Qnil), Qnil). Similarly for list2 through list5. * buffer.c (Fget_buffer_create, Fmake_indirect_buffer): * bytecode.c (exec_byte_code): * callint.c (quotify_arg, Fcall_interactively): * callproc.c (Fcall_process, create_temp_file): * charset.c (load_charset_map_from_file) (Fdefine_charset_internal, init_charset): * coding.c (get_translation_table, detect_coding_system) (Fcheck_coding_systems_region) (Fset_terminal_coding_system_internal) (Fdefine_coding_system_internal, Fdefine_coding_system_alias): * composite.c (update_compositions, Ffind_composition_internal): * dired.c (directory_files_internal, file_name_completion) (Fsystem_users): * dispnew.c (Fopen_termscript, bitch_at_user, init_display): * doc.c (Fsnarf_documentation): * editfns.c (Fmessage_box): * emacs.c (main): * eval.c (do_debug_on_call, signal_error, maybe_call_debugger) (Feval, eval_sub, Ffuncall, apply_lambda): * fileio.c (make_temp_name, Fcopy_file, Faccess_file) (Fset_file_selinux_context, Fset_file_acl, Fset_file_modes) (Fset_file_times, Finsert_file_contents) (Fchoose_write_coding_system, Fwrite_region): * fns.c (Flax_plist_put, Fyes_or_no_p, syms_of_fns): * font.c (font_registry_charsets, font_parse_fcname) (font_prepare_cache, font_update_drivers, Flist_fonts): * fontset.c (Fset_fontset_font, Ffontset_info, syms_of_fontset): * frame.c (make_frame, Fmake_terminal_frame) (x_set_frame_parameters, x_report_frame_params) (x_default_parameter, Fx_parse_geometry): * ftfont.c (syms_of_ftfont): * image.c (gif_load): * keyboard.c (command_loop_1): * keymap.c (Fmake_keymap, Fmake_sparse_keymap, access_keymap_1) (Fcopy_keymap, append_key, Fcurrent_active_maps) (Fminor_mode_key_binding, accessible_keymaps_1) (Faccessible_keymaps, Fwhere_is_internal): * lread.c (read_emacs_mule_char): * menu.c (find_and_return_menu_selection): * minibuf.c (get_minibuffer): * nsfns.m (Fns_perform_service): * nsfont.m (ns_script_to_charset): * nsmenu.m (ns_popup_dialog): * nsselect.m (ns_get_local_selection, ns_string_from_pasteboard) (Fx_own_selection_internal): * nsterm.m (append2): * print.c (Fredirect_debugging_output) (print_prune_string_charset): * process.c (Fdelete_process, Fprocess_contact) (Fformat_network_address, set_socket_option) (read_and_dispose_of_process_output, write_queue_push) (send_process, exec_sentinel): * sound.c (Fplay_sound_internal): * textprop.c (validate_plist, add_properties) (Fput_text_property, Fadd_face_text_property) (copy_text_properties, text_property_list, syms_of_textprop): * unexaix.c (report_error): * unexcoff.c (report_error): * unexsol.c (unexec): * xdisp.c (redisplay_tool_bar, store_mode_line_string) (Fformat_mode_line, syms_of_xdisp): * xfaces.c (set_font_frame_param) (Finternal_lisp_face_attribute_values) (Finternal_merge_in_global_face, syms_of_xfaces): * xfns.c (x_default_scroll_bar_color_parameter) (x_default_font_parameter, x_create_tip_frame): * xfont.c (xfont_supported_scripts): * xmenu.c (Fx_popup_dialog, xmenu_show, xdialog_show) (menu_help_callback, xmenu_show): * xml.c (make_dom): * xterm.c (set_wm_state): Prefer list1 (FOO) to Fcons (FOO, Qnil) when creating a list, and similarly for list2 through list5.
* * callproc.c (Fcall_process_region): Fix minor race and tune.Paul Eggert2013-07-141-59/+77
| | | | | | | | | | | | | | (create_temp_file): New function, with the temp-file-creation part of the old Fcall_process_region. Use Fcopy_sequence to create the temp file name, rather than alloca + build_string, for simplicity. Don't bother to block input around the temp file creation; shouldn't be needed. Simplify use of mktemp. Use record_unwind_protect immediately after creating the temp file; this closes an unlikely race where the temp file was not removed. Use memcpy rather than an open-coded loop. (Fcall_process_region): Use the new function. If the input is empty, redirect from /dev/null rather than from a newly created empty temp file; this avoids unnecessary file system traffic.
* * callproc.c (child_setup, relocate_fd) [!DOS_NT]:Paul Eggert2013-07-131-12/+7
| | | | | * process.c (create_process) [!DOS_NT]: Remove now-unnecessary calls to emacs_close.
* Clean up errno reporting and fix some errno-reporting bugs.Paul Eggert2013-07-121-37/+37
| | | | | | | | | | | | | | | | | | | | | | | | * callproc.c (Fcall_process): * fileio.c (Fcopy_file, Finsert_file_contents, Fwrite_region): * process.c (create_process, Fmake_network_process): * unexaix.c (report_error): * unexcoff.c (report_error): Be more careful about reporting the errno of failed operations. The code previously reported the wrong errno sometimes. Also, prefer report_file_errno to setting errno + report_file_error. (Fcall_process): Look at openp return value rather than at path, as that's a bit faster and clearer when there's a numeric predicate. * fileio.c (report_file_errno): New function, with most of the old contents of report_file_error. (report_file_error): Use it. (Ffile_exists_p, Ffile_accessible_directory_p): Set errno to 0 when it is junk. * fileio.c (Faccess_file): * image.c (x_create_bitmap_from_file): Use faccessat rather than opening the file, to avoid the hassle of having a file descriptor open. * lisp.h (report_file_errno): New decl. * lread.c (Flocate_file_internal): File descriptor 0 is valid, too.
* Fix races with threads and file descriptors.Paul Eggert2013-07-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | * configure.ac (PTY_TTY_NAME_SPRINTF): Use emacs_close, not close. * src/callproc.c (Fcall_process_region): * src/dired.c (open_directory): * src/emacs.c (main, Fdaemon_initialized): * src/image.c (x_find_image_file): * src/inotify.c (Finotify_rm_watch): * src/lread.c (Flocate_file_internal): * src/process.c (Fnetwork_interface_list, Fnetwork_interface_info): * src/term.c (term_mouse_moveto, init_tty): * src/termcap.c (tgetent): * src/unexaix.c, src/unexcoff.c (report_error, report_error_1, adjust_lnnoptrs) * src/unexaix.c, src/unexcoff.c, src/unexcw.c, src/unexelf.c (unexec): * src/unexhp9k800.c, src/unexmacosx.c (unexec): * src/callproc.c (Fcall_process_region): Use emacs_close, not close. * src/sysdep.c (POSIX_CLOSE_RESTART, posix_close) [!POSIX_CLOSE_RESTART]: New macro and function, which emulates the POSIX_CLOSE_RESTART macro and posix_close function on current platforms (which all lack them). (emacs_close): Use it. This should fix the races on GNU/Linux and on AIX and on future platforms that support POSIX_CLOSE_RESTART, and it should avoid closing random victim file descriptors on other platforms.
* Handle errno and exit status a bit more carefully.Paul Eggert2013-07-091-12/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib/ignore-value.h: Remove this gnulib-imported file. * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate. * admin/merge-gnulib (GNULIB_MODULES): Remove ignore-value. * src/callproc.c (child_setup) [!DOS_NT]: Don't try to stuff an error number into an exit status. Instead, use EXIT_CANCELED. (child_setup) [!MSDOS]: Avoid possible deadlock with vfork. * src/callproc.c (relocate_fd): * src/emacs.c (close_output_streams, main): * src/process.c (create_process): * src/sysdep.c (sys_subshell) [!DOS_NT || !WINDOWSNT]: Use emacs_perror for simplicity. * src/callproc.c (relocate_fd, main): * src/sysdep.c (sys_subshell): Exit with EXIT_CANCELED etc., not 1, when exec setup fails. (shut_down_emacs): Use emacs_write, not write. * src/emacs.c, src/sysdep.c: Don't include <ignore-value.h>. * src/fileio.c (Fcopy_file, e_write): * src/nsterm.m (ns_select): * src/process.c (send_process): * src/sound.c (vox_write): Use emacs_write_sig, not emacs_write. * src/lisp.h (emacs_write_sig, emacs_perror): New decls. * src/process.h (EXIT_CANCELED), EXIT_CANNOT_INVOKE, EXIT_ENOENT): New constants. * src/sysdep.c (emacs_backtrace): Use emacs_write, not ignore_value of write. (emacs_full_write): New function. (emacs_write): Rewrite to use it. (emacswrite_sig, emacs_perror): New functions. * src/xrdb.c (fatal): Don't invoke perror, since errno might be garbage.
* MS-Windows followup for 2013-07-07T18:00:[email protected].Eli Zaretskii2013-07-071-0/+1
| | | | | | | | | | | nt/inc/sys/socket.h (F_SETFD, O_CLOEXEC, F_DUPFD_CLOEXEC) (FD_CLOEXEC): New macros. src/w32.c (sys_dup): Declare prototype. src/filelock.c: src/emacs.c: src/callproc.c [WINDOWSNT]: Include sys/socket.h.
* Make file descriptors close-on-exec when possible.Paul Eggert2013-07-071-12/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This simplifies Emacs a bit, since it no longer needs to worry about closing file descriptors by hand in some cases. It also fixes some unlikely races. Not all such races, as libraries often open files internally without setting close-on-exec, but it's an improvement. * admin/merge-gnulib (GNULIB_MODULES): Add fcntl, pipe2. (GNULIB_TOOL_FLAGS): Avoid binary-io, close. Do not avoid fcntl. * configure.ac (mkostemp): New function to check for. (PTY_OPEN): Pass O_CLOEXEC to posix_openpt. * lib/fcntl.c, lib/getdtablesize.c, lib/pipe2.c, m4/fcntl.m4: * m4/getdtablesize.m4, m4/pipe2.m4: New files, taken from gnulib. * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate. * nt/gnulib.mk: Remove empty gl_GNULIB_ENABLED_verify section; otherwise, gnulib-tool complains given close-on-exec changes. * nt/inc/ms-w32.h (pipe): Remove. * nt/mingw-cfg.site (ac_cv_func_fcntl, gl_cv_func_fcntl_f_dupfd_cloexec) (gl_cv_func_fcntl_f_dupfd_works, ac_cv_func_pipe2): New vars. * src/alloc.c (valid_pointer_p) [!WINDOWSNT]: * src/callproc.c (Fcall_process) [!MSDOS]: * src/emacs.c (main) [!DOS_NT]: * src/nsterm.m (ns_term_init): * src/process.c (create_process): Use 'pipe2' with O_CLOEXEC instead of 'pipe'. * src/emacs.c (Fcall_process_region) [HAVE_MKOSTEMP]: * src/filelock.c (create_lock_file) [HAVE_MKOSTEMP]: Prefer mkostemp with O_CLOEXEC to mkstemp. * src/callproc.c (relocate_fd) [!WINDOWSNT]: * src/emacs.c (main): Use F_DUPFD_CLOEXEC, not plain F_DUPFD. No need to use fcntl (..., F_SETFD, FD_CLOEXEC), since we're now using pipe2. * src/filelock.c (create_lock_file) [! HAVE_MKOSTEMP]: Make the resulting file descriptor close-on-exec. * src/lisp.h, src/lread.c, src/process.c (close_load_descs, close_process_descs): * src/lread.c (load_descriptor_list, load_descriptor_unwind): Remove; no longer needed. All uses removed. * src/process.c (SOCK_CLOEXEC): Define to 0 if not supplied by system. (close_on_exec, accept4, process_socket) [!SOCK_CLOEXEC]: New functions. (socket) [!SOCK_CLOEXEC]: Supply a substitute. (Fmake_network_process, Fnetwork_interface_list): (Fnetwork_interface_info, server_accept_connection): Make newly-created socket close-on-exec. * src/sysdep.c (emacs_open, emacs_fopen): Make new-created descriptor close-on-exec. * src/w32.c (fcntl): Support F_DUPFD_CLOEXEC well enough for Emacs. * src/w32.c, src/w32.h (pipe2): Rename from 'pipe', with new flags arg. Fixes: debbugs:14803
* Fix openp errno handling.Paul Eggert2013-07-071-0/+2
| | | | | | * callproc.c (Fcall_process): Preserve openp errno around close. * lread.c (openp): Set errno when returning -1, as some callers expect this.
* Use emacs_open more consistently when opening files.Paul Eggert2013-07-051-16/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This handles EINTR more consistently now, and makes it easier to introduce other uniform changes to file descriptor handling. * src/systdio.h: New file. * src/buffer.c (mmap_init): * cygw32.c (chdir_to_default_directory): * dispnew.c (Fopen_termscript): * emacs.c (Fdaemon_initialized): * fileio.c (Fdo_auto_save): * image.c (slurp_file, png_load_body, jpeg_load_body): * keyboard.c (Fopen_dribble_file): * lread.c (Fload): * print.c (Fredirect_debugging_output): * sysdep.c (get_up_time, procfs_ttyname, procfs_get_total_memory): * termcap.c (tgetent): * unexaix.c, unexcoff.c (unexec, adjust_lnnoptrs): * unexcw.c, unexelf.c, unexhp9k800.c, unexmacosx.c (unexec): * w32term.c (w32_initialize) [CYGWIN]: * xfaces.c (Fx_load_color_file): Use emacs_open instead of plain open, and emacs_fopen instead of plain fopen. * dispnew.c, fileio.c, image.c, keyboard.c, lread.c, print.c, sysdep.c: * xfaces.c: Include sysstdio.h rather than stdio.h, for emacs_fopen. * callproc.c (default_output_mode): New constant. (Fcall_process): Use it to call emacs_open instead of plain creat. * dispnew.c (Fopen_termscript): Fix minor race in opening termscript. * sysdep.c (emacs_open): Add commentary and don't call file name "path". (emacs_fopen): New function. * unexaix.c, unexcoff.c, unexelf.c, unexhp9k800.c, unexmacosx.c: Include <lisp.h>, for emacs_open. * unexelf.c (fatal): Remove decl; not needed with <lisp.h> included.
* Do not tickle glib SIGCHLD handling if Cygwin.Paul Eggert2013-06-271-1/+0
| | | | | | | | | | | | | | | | | This mostly consists of undoing recent changes. * callproc.c (Fcall_process): * process.c (create_process): Do not worry about catching SIGCHLD here, undoing previous change. * nsterm.m (ns_term_init): Re-catch SIGCHLD, undoing previous change. * process.c, process.h (catch_child_signal): No longer extern if !NS_IMPL_GNUSTEP, undoing 06-22 change. * process.c (catch_child_handler): Don't worry about being called lazily and do not assume caller has blocked SIGCHLD, undoing previous change. Move first-time stuff back to init_process_emacs, undoing 06-22 change. If CYGWIN, do not tickle glib, as that causes Cygwin bootstrap to fail. Do not set lib_child_handler if it's already initialized, which may help avoid problems on GNUStep.
* A more-conservative workaround for Cygwin SIGCHLD issues.Paul Eggert2013-06-231-0/+1
| | | | | | | | | | | | | | | | | | * callproc.c (Fcall_process): * process.c (create_process): Make sure SIGCHLD is caught before we fork, since Emacs startup no arranges to catch SIGCHLD. * process.c (lib_child_handler): Initialize to null, not to dummy_handler. (catch_child_signal): Allow self to be called lazily. Do nothing if it's already been called. Assume caller has blocked SIGCHLD (all callers do now). * emacs.c (main): Do not catch SIGCHLD here; defer it until just before it's really needed. * nsterm.m (ns_term_init): No need to re-catch SIGCHLD here, since it hasn't been caught yet. Fixes: debbugs:14569
* Try to avoid malloc SEGVs on Cygwin.Paul Eggert2013-06-231-2/+2
| | | | | | | | | | | | | * callproc.c, process.h (block_child_signal, unblock_child_signal): Now extern. * emacs.c (main): Catch SIGCHLD just before initializing gfilenotify. * process.c (catch_child_signal): Block SIGCHLD while futzing with the SIGCHLD handler, since the code is not atomic and (due to glib) signals may be arriving now. * sysdep.c (init_signals): Do not catch child signals here; 'main' now does that later, at a safer time. Fixes: debbugs:14569
* * callproc.c (call_process): Refine the doc string. (Bug#14045)Xue Fuqiao2013-05-251-4/+4
|