aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Allow :filter t in make-process to work as with set-process-filterLars Ingebrigtsen2021-10-181-4/+8
| | | | | | | | * src/process.c (create_process): (create_pty): (Fmake_pipe_process): (Fmake_serial_process): Don't add the read_fd if the filter is t (which means that we don't accept output from the filter).
* Avoid aborts when a thread is signaled while "waiting for input".Eli Zaretskii2021-10-161-3/+19
| | | | | | | | * src/process.c (kbd_is_ours): New function. (wait_reading_process_output): Set 'waiting_for_input' only if the current thread is monitoring the keyboard descriptor. See also https://lists.gnu.org/archive/html/emacs-devel/2021-10/msg01180.html. (Bug#51229)
* New function num-processorsPaul Eggert2021-10-101-0/+18
| | | | | | | | | | | | | | | | | | | This addresses a FIXME comment in lisp/emacs-lisp/comp.el, relating to the number of subsidiary processes used by comp-run-async-workers in native compilation. * admin/merge-gnulib (GNULIB_MODULES): Add nproc. * doc/lispref/processes.texi (Process Information), etc/NEWS: Document num-processors. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate. * lib/nproc.c, lib/nproc.h, m4/nproc.m4: New files, copied from Gnulib by admin/merge-gnulib. * lisp/emacs-lisp/comp.el (w32-get-nproc): Remove decl. (comp-effective-async-max-jobs): Use num-processors. * src/process.c: Include nproc.h. (Fnum_processors): New function. (syms_of_process): Define ‘all’, ‘current’, ‘num-processors’. * src/w32proc.c (Fw32_get_nproc): Add FIXME comment. * test/src/process-tests.el (process-num-processors): New test.
* Port unused decls to C2xPaul Eggert2021-10-031-1/+1
| | | | | * src/conf_post.h (ATTRIBUTE_UNUSED): Remove. All uses replaced by MAYBE_UNUSED, and moved to start as needed for C2x.
* Don't quote nil and t in doc strings and commentsLars Ingebrigtsen2021-09-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * test/src/minibuf-tests.el (test-try-completion-ignore-case): * test/lisp/url/url-auth-tests.el (url-auth-test-digest-auth-retrieve-cache): * test/lisp/subr-tests.el (subr-tests-add-hook-depth): * test/lisp/so-long-tests/so-long-tests.el (so-long-tests-invisible-buffer-function): * test/lisp/emacs-lisp/tabulated-list-test.el (tabulated-list-sort): * src/xfaces.c: * src/process.c (Finterrupt_process): (syms_of_process): * src/minibuf.c (Fread_from_minibuffer): (Fcompleting_read): (syms_of_minibuf): * src/dispnew.c (syms_of_display): * src/data.c: * lisp/so-long.el (so-long--hack-local-variables): * lisp/progmodes/elisp-mode.el (elisp--xref-find-definitions): (elisp--xref-find-definitions): * lisp/org/ox-html.el (org-html-htmlize-output-type): * lisp/org/org-agenda.el (org-agenda-do-in-region): * lisp/net/tramp.el: * lisp/minibuffer.el (set-minibuffer-message): * lisp/isearch.el (isearch-wrap-pause): (isearch-repeat-on-direction-change): * lisp/emacs-lisp/timer.el (timer): * lisp/emacs-lisp/package.el (package-read-archive-contents): * lisp/emacs-lisp/faceup.el (faceup-next-property-change): * lisp/emacs-lisp/comp.el (comp-func): * lisp/emacs-lisp/comp-cstr.el (comp-cstr-empty-p): * lisp/emacs-lisp/cl-macs.el (cl-do): (cl-do*): (cl--self-tco): * lisp/emacs-lisp/bytecomp.el (byte-compile-unresolved-functions): (byte-compile-cond-jump-table): Don't quote t and nil.
* Clarify :stderr in the make-process doc stringLars Ingebrigtsen2021-08-231-1/+4
| | | | | * src/process.c (Fmake_process): Elaborate upon what :stderr does (bug#50166).
* Block TLS handshake until TCP connection establishedMattias Engdegård2021-07-131-1/+4
| | | | | | | | | | | | | | | | | | | If a TLS handshake is attempted before the completion of an asynchronous TCP connection has been ascertained, our local state will not be set up correctly for further progress and the sentinel "open" event will never be sent. This can occur if sufficient time passes after the initiation of an async TCP connection so that by the time `wait_reading_process_output` is called, the connection has already been established on the TCP level. This somewhat timing-sensitive bug has plagued HTTPS connections on some platforms, notably macOS, for a long time (bug#49449). * src/process.c (wait_reading_process_output): Gate the TLS handshake by the NON_BLOCKING_CONNECT_FD flag. The flag will be cleared as soon as the TCP socket is found to be writable. * test/src/process-tests.el (process-async-https-with-delay): New test.
* Ensure 'call-process' interprets INFILE as a local pathJim Porter2021-07-041-1/+1
| | | | | | | | | | | | * src/callproc.c (get_current_directory): Rename from 'encode_current_directory' and add boolean ENCODE flag. (Fcall_process): Interpret INFILE relative to the working directory from which PROGRAM is run, not 'default-directory'. (call_process): Use 'get_current_directory'. * src/process.c (Fmake_process): Use 'get_current_directory'. * src/process.h (get_current_directory): Rename decl from 'encode_current_directory'. * src/sysdep.c (sys_subshell): Use 'get_current_directory' (bug#49283).
* Fix documentation of a recent changeEli Zaretskii2021-05-251-4/+7
| | | | | | | * src/process.c (syms_of_process) <process-prioritize-lower-fds>: Doc fix. * etc/NEWS: Reword the entry for 'process-prioritize-lower-fds'.
* Try to not prioritise reading from lower file descriptorsMiha Rihtaršič2021-05-251-1/+25
| | | | | | | * src/process.c (wait_reading_process_output): When looping through fds, continue from where we left off. (syms_of_process): Vprocess_prioritize_lower_fds: New variable (bug#48118).
* Process sentinels need to work under X and commandlinedickmao2021-05-131-7/+8
| | | | | | | | * src/process.c (add_non_keyboard_read_fd): Make this a public function. (add_process_read_fd): Fold old, static add_non_keyboard_read_fd guts into here. * src/xsmfns.c (ice_conn_watch_CB): Call add_non_keyboard_read_fd (bug#43834).
* Do not load native code when `load' is explicitly called on a .elc fileAndrea Corallo2021-03-191-1/+1
| | | | | | | | | | | | | | | | | | | * src/lread.c (Fload): Do not load native code when `load' is explicitly called on a .elc file. (Flocate_file_internal): Update 'openp' call sites. (maybe_swap_for_eln): Add new 'no_native' parameter. (openp): Likewise + update 'maybe_swap_for_eln' and 'openp' call sites. * src/lisp.h: Update 'openp' signature. * src/w32proc.c (sys_spawnve): Update 'openp' call sites. * src/w32.c (check_windows_init_file): Likewise. * src/sound.c (Fplay_sound_internal): Likewise. * src/process.c (Fmake_process): Likewise. * src/image.c (image_create_bitmap_from_file) (image_find_image_fd): Likewise. * src/emacs.c (set_invocation_vars): Likewise. * src/charset.c (load_charset_map_from_file): Likewise. * src/callproc.c (call_process): Likewise.
* Fix typosMattias Engdegård2021-02-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * doc/lispref/display.texi (Size of Displayed Text): * doc/lispref/windows.texi (Buffer Display Action Functions): * etc/NEWS: * etc/ORG-NEWS (Org-Attach has been refactored and extended): * lisp/battery.el (display-battery-mode, battery--upower-subsribe): * lisp/calendar/parse-time.el: * lisp/dired-x.el: * lisp/emacs-lisp/chart.el (chart-sequece, chart-bar-quickie): * lisp/emacs-lisp/eldoc.el (eldoc-echo-area-use-multiline-p) (eldoc-documentation-strategy): * lisp/emacs-lisp/pcase.el (pcase--split-pred, pcase--u1): * lisp/gnus/gnus-search.el (gnus-search-expandable-keys) (gnus-search-parse-query, gnus-search-query-return-string) (gnus-search-imap, gnus-search-imap-search-command) (gnus-search-transform-expression): * lisp/gnus/nnselect.el: * lisp/isearch.el (isearch-lazy-count-format): * lisp/mh-e/mh-show.el (mh-show-msg): * lisp/net/dictionary-connection.el (dictionary-connection-open): * lisp/net/dictionary.el (dictionary-default-popup-strategy) (dictionary, dictionary-split-string, dictionary-do-select-dictionary) (dictionary-display-dictionarys, dictionary-search) (dictionary-tooltip-mode): * lisp/net/eudcb-macos-contacts.el (eudc-macos-contacts-set-server): * lisp/net/mailcap.el (mailcap-mime-data): * lisp/net/tramp-smb.el (tramp-smb-maybe-open-connection): * lisp/nxml/nxml-mode.el (nxml-mode): * lisp/progmodes/cc-engine.el: * lisp/progmodes/cperl-mode.el (cperl-mode) (cperl-fontify-syntaxically): * lisp/progmodes/flymake.el (flymake-diagnostic-functions): * lisp/progmodes/verilog-mode.el (verilog--supressed-warnings) (verilog-preprocess): * lisp/simple.el (self-insert-uses-region-functions): * lisp/textmodes/bibtex.el (bibtex-copy-summary-as-kill): * lisp/textmodes/texnfo-upd.el (texinfo-insert-master-menu-list): * src/dispnew.c: * src/font.c (Ffont_get): * src/indent.c (compute_motion): * src/process.c (init_process_emacs): * src/w32fns.c (deliver_wm_chars): * test/lisp/jsonrpc-tests.el (deferred-action-complex-tests): Fix typos in documentation, comments, and internal identifiers.
* ; * src/process.c (child_signal_read): Don't report EAGAIN as errorMattias Engdegård2021-01-291-1/+1
|
* ; * src/process.c (child_signal_read): Remove FIXME comment.Eli Zaretskii2021-01-231-1/+0
|
* Add a FIXME comment to improve the SIGCHLD race condition handling.Philipp Stephani2021-01-231-0/+5
| | | | | * src/process.c: Add FIXME comment describing how we could avoid the self-pipe on modern Unix-like systems.
* Mark both ends of self-pipe a nonblocking.Philipp Stephani2021-01-231-0/+2
| | | | | | | | | While no deadlocks caused by the blocking write end have been reported yet, marking both ends nonblocking is consistent and also recommended in the GNU/Linux manpage of 'select'. * src/process.c (child_signal_init): Mark write end of self-pipe as nonblocking.
* Clean up the recently added self-pipe mechanism for WINDOWSNTEli Zaretskii2021-01-231-2/+21
| | | | | * src/process.c (child_signal_init, child_signal_read) (child_signal_notify): #ifdef away on WINDOWSNT.
* Make child signal read pipe non-blocking.Philipp Stephani2021-01-191-0/+2
| | | | | | | | | Otherwise Emacs might hang when trying to read the pipe twice in a row. This is consistent with the other file descriptors we pass to 'pselect'. * src/process.c (child_signal_init): Make read end of pipe non-blocking.
* Ensure that sentinels are called during 'accept-process-output'.Philipp Stephani2021-01-171-0/+9
| | | | | | | | | | | | When we're trying to notify a process about a status change, we need to ignore the SIGCHLD pipe temporarily, otherwise the code would likely not run into the timeout case that's necessary for a status change to happen. * src/process.c (wait_reading_process_output): Ignore the SIGCHLD pipe when notifying a process about a status change. * test/src/process-tests.el (process-tests/sentinel-called) (process-tests/sentinel-with-multiple-processes): New unit tests.
* Don't crash if no asynchronous process has been created yet.scratch/sigchld-fdPhilipp Stephani2021-01-161-2/+2
| | | | | * src/process.c (wait_reading_process_output): Allow child_signal_read_fd < 0.
* Fix deadlock when receiving SIGCHLD during 'pselect'.Philipp Stephani2021-01-161-1/+93
| | | | | | | | | | | | | | | | | | | | | | If we receive and handle a SIGCHLD signal for a process while waiting for that process, 'pselect' might never return. Instead, we have to explicitly 'pselect' that the process status has changed. We do this by writing to a pipe in the SIGCHLD handler and having 'wait_reading_process_output' select on it. * src/process.c (child_signal_init): New helper function to create a pipe for SIGCHLD notifications. (child_signal_read, child_signal_notify): New helper functions to read from/write to the child signal pipe. (create_process): Initialize the child signal pipe on first use. (handle_child_signal): Notify waiters that a process status has changed. (wait_reading_process_output): Make sure that we also catch SIGCHLD/process status changes. * test/src/process-tests.el (process-tests/fd-setsize-no-crash/make-process): Remove workaround, which is no longer needed.
* Remove a pointless check for WCOREDUMPED.Philipp Stephani2021-01-101-2/+1
| | | | | | | WCOREDUMPED can only be used if the process was killed. * src/process.c (status_convert): Don't check WCOREDUMPED if WIFEXITED.
* Don't unblock SIGCHLD too early.Philipp Stephani2021-01-091-1/+9
| | | | | | | | | | | | We first need to register the received process ID so that 'handle_child_signal' checks it. Otherwise we might never call 'waitpid' for these processes, risking deadlock. * src/callproc.c (call_process): * src/process.c (create_process): Don't unblock SIGCHLD before registering the process ID to wait for. * src/callproc.c (emacs_spawn): Accept a signal set from the caller.
* Port to Solaris 10Paul Eggert2021-01-011-9/+0
| | | | | | | | | | | | | | | | | | | | | | * configure.ac: Instead of AC_CHECK_HEADER, use AC_COMPILE_IFELSE with X11/Intrinsic.h when checking for X11/extensions/Xrender.h. This suppresses a bogus "report a bug to bug-gnu-emacs" diagnostic from 'configure' in Solaris 10. (SETUP_SLAVE_PTY): Adjust to recent renaming of forkin to std_in in callproc.c. Needed on Solaris and Unixware. * lib-src/Makefile.in (LIB_GETRANDOM, LIBS_ETAGS): New vars, needed because on Solaris 10 the Gnulib tempname module now needs the -lrt library for clock_gettime. Throw in the LIB_GETRANDOM stuff too while we’re at it; from getrandom.m4 it seems to be needed for MingW. (LIBS_MOVE, etags_libs): Use them. * src/callproc.c [SETUP_SLAVE_PTY]: Include sys/stream.h and sys/stropts.h, for SETUP_SLAVE_PTY’s definiens. * src/process.c [NEED_BSDTTY]: Don’t include bsdtty.h; hasn’t been needed in years. [USG5_4]: Don’t include sys/stream.h or sys/stropts.h; these directives havbe been moved to callproc.c because the only use of SETUP_SLAVE_PTY is there now.
* Merge from origin/emacs-27Paul Eggert2021-01-011-2/+3
|\ | | | | | | | | | | 74a77ef299 Improve documentation of 'network-lookup-address-info' c6d5555646 Display messages sent using ERC's /say c156723769 Fix Rmail summary display when From: header is malformed
| * Improve documentation of 'network-lookup-address-info'Eli Zaretskii2020-12-311-2/+3
| | | | | | | | | | | | * src/process.c (Fnetwork_lookup_address_info): * doc/lispref/processes.texi (Misc Network): Document the error message emitted by 'network-lookup-address-info' when it fails.
* | Update copyright year to 2021Paul Eggert2021-01-011-1/+1
| | | | | | | | Run "TZ=UTC0 admin/update-copyright".
* | Minor improvements to FD_SETSIZE overflow checks.Philipp Stephani2020-12-311-1/+2
| | | | | | | | | | * src/process.c (Fmake_serial_process): Add port to error data. (connect_network_socket): Add an explanatory comment.
* | Manually limit file descriptors that we select on to FD_SETSIZE.Philipp Stephani2020-12-311-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This works even if another thread or process resets the resource limit for open file descriptors, e.g., using 'prlimit' on GNU/Linux. * src/process.c (create_process, create_pty, Fmake_pipe_process) (Fmake_serial_process, connect_network_socket) (server_accept_connection): Limit file descriptors to FD_SETSIZE. * test/src/process-tests.el (process-tests--with-raised-rlimit): New helper macro. (process-tests--fd-setsize-test): Rename from 'process-tests--with-many-pipes'. Increase resource limit during test if possible. (process-tests/fd-setsize-no-crash/make-process) (process-tests/fd-setsize-no-crash/make-pipe-process) (process-tests/fd-setsize-no-crash/make-network-process) (process-tests--new-pty): Rename callers.
* | Consistently check for FD_SETSIZE overflow.Philipp Stephani2020-12-301-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously this was only checked in a few places. Now assert that file descriptors are within the expected range whenever we'd otherwise introduce undefined behavior. * src/process.c (add_read_fd, add_process_read_fd, delete_read_fd) (recompute_max_desc, delete_write_fd, compute_input_wait_mask) (compute_non_process_wait_mask, compute_non_keyboard_wait_mask) (compute_write_mask, clear_waiting_thread_info) (update_processes_for_thread_death, Fset_process_thread) (create_process, create_pty, Fmake_pipe_process) (Fprocess_datagram_address, Fset_process_datagram_address) (Fmake_serial_process, finish_after_tls_connection) (connect_network_socket, deactivate_process) (server_accept_connection, wait_reading_process_output) (read_process_output, read_and_dispose_of_process_output) (send_process, Fcontinue_process, Fprocess_send_eof) (Fprocess_filter_multibyte_p, keyboard_bit_set) (add_timer_wait_descriptor, setup_process_coding_systems): Add assertions to document and check that file descriptors are within the expected range when used as file descriptor set elements or array subscripts.
* | Fix test/src/process-tests on MS-WindowsEli Zaretskii2020-12-261-0/+6
| | | | | | | | | | * src/process.c (network_lookup_address_info_1) [WINDOWSNT]: Initialize winsock.
* | Unbreak the MinGW build broken by recent changes in callproc.cEli Zaretskii2020-12-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/w32.h (set_process_dir): * src/w32proc.c (set_process_dir): Change the argument to 'const char *'. * src/lisp.h (make_environment_block): * src/callproc.c (make_environment_block): Now returns 'char **'. (exec_failed) [DOS_NT]: Remove unused function. * src/callproc.c (child_setup): NEW_ARGV and ENV are now 'char **'. Making them 'const' breaks the MinGW build and is not needed for other platforms. * src/callproc.c (emacs_spawn): ARGV and ENVP arguments are now 'char *', for the same reason. * src/process.c (create_process): Adapt to above changes.
* | Centralize subprocess creation in a single function.Philipp Stephani2020-12-241-142/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Getting the vfork + execve combination right isn't easy, and the code was partially duplicated between callproc.c and process.c. Centralize the spawn operation in a single function that deals with the nasty details. Going forward, we should be able to use posix_spawn from either libc or Gnulib (or CreateProcessW on Windows) in the non-pty case. * src/callproc.c (emacs_spawn): New function to start an asynchronous subprocess. Merge code from 'call_process' and 'create_process' into this function. (call_process): Use new 'emacs_spawn' function. (child_setup): Make static, since there are no users outside this compilation unit left. (CHILD_SETUP_TYPE): Move from header file, since there are no users outside this compilation unit left. * src/process.c (create_process): Use new 'emacs_spawn' function.
* | Pass C string pointer to current directory to 'child_setup'.Philipp Stephani2020-12-231-2/+4
| | | | | | | | | | | | | | | | | | | | | | This avoids the impression that 'child_setup' could do anything Lisp-related. * src/callproc.c (child_setup): Pass C pointer to current directory name. (call_process): Adapt callers. * src/process.c (create_process): Adapt callers.
* | Allocate environment block before forking.Philipp Stephani2020-12-231-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While 'child_setup' carefully avoids calls to async-signal-unsafe functions like 'malloc', it seems simpler and less brittle to use normal allocation outside the critical section between 'fork' and 'exec'. * src/callproc.c (make_environment_block): New function to create the environment block for subprocesses. Code largely extracted from 'child_setup' and adapted to use 'xmalloc' instead of 'alloca'. (child_setup): Remove environment block allocation in favor of passing the environment block as command-line argument. (call_process): Adapt to new calling convention. * src/process.c (create_process): Adapt to new calling convention.
* | Remove an unused parameter from 'child_setup' function.Philipp Stephani2020-12-231-2/+2
| | | | | | | | | | | | | | * src/callproc.c (child_setup): Remove unused SET_PGRP parameter. * src/callproc.c (call_process): * src/process.c (create_process): Fix all callers.
* | Inhibit buffer hooks in temporary buffersBasil L. Contovounesios2020-12-201-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Give get-buffer-create an optional argument to inhibit buffer hooks in internal or temporary buffers for efficiency (bug#34765). * etc/NEWS: Announce new parameter of get-buffer-create and generate-new-buffer, and that with-temp-buffer and with-temp-file now inhibit buffer hooks. * doc/lispref/buffers.texi (Buffer Names): Fix typo. (Creating Buffers): Document new parameter of get-buffer-create and generate-new-buffer. (Buffer List, Killing Buffers): Document when buffer hooks are inhibited. (Current Buffer): * doc/lispref/files.texi (Writing to Files): Document that with-temp-buffer and with-temp-file inhibit buffer hooks. * doc/lispref/internals.texi (Buffer Internals): Document inhibit_buffer_hooks flag. Remove stale comment. * doc/misc/gnus-faq.texi (FAQ 5-8): * lisp/simple.el (shell-command-on-region): Fix indentation. * lisp/files.el (kill-buffer-hook): Document when hook is inhibited. (create-file-buffer): * lisp/gnus/gnus-uu.el (gnus-uu-unshar-article): * lisp/international/mule.el (load-with-code-conversion): * lisp/mh-e/mh-xface.el (mh-x-image-url-fetch-image): * lisp/net/imap.el (imap-open): * lisp/net/mailcap.el (mailcap-maybe-eval): * lisp/progmodes/flymake-proc.el (flymake-proc--read-file-to-temp-buffer) (flymake-proc--copy-buffer-to-temp-buffer): Simplify. * lisp/subr.el (generate-new-buffer): Forward new optional argument to inhibit buffer hooks to get-buffer-create. (with-temp-file, with-temp-buffer, with-output-to-string): * lisp/json.el (json-encode-string): Inhibit buffer hooks in buffer used. * src/buffer.c (run_buffer_list_update_hook): New helper function. (Fget_buffer_create): Use it. Add optional argument to set inhibit_buffer_hooks flag instead of comparing the buffer name to Vcode_conversion_workbuf_name. All callers changed. (Fmake_indirect_buffer, Frename_buffer, Fbury_buffer_internal) (record_buffer): Use run_buffer_list_update_hook. (Fkill_buffer): Document when buffer hooks are inhibited. Use run_buffer_list_update_hook. (init_buffer_once): Inhibit buffer hooks in Vprin1_to_string_buffer. (Vkill_buffer_query_functions, Vbuffer_list_update_hook): Document when hooks are inhibited. * src/buffer.h (struct buffer): Update inhibit_buffer_hooks commentary. * src/coding.h (Vcode_conversion_workbuf_name): * src/coding.c (Vcode_conversion_workbuf_name): Make static again since it is no longer needed in src/buffer.c. (code_conversion_restore, code_conversion_save, syms_of_coding): Prefer boolean over integer constants. * src/fileio.c (Finsert_file_contents): Inhibit buffer hooks in " *code-converting-work*" buffer. * src/window.c (Fselect_window): Fix grammar. Mention window-selection-change-functions alongside buffer-list-update-hook. * test/src/buffer-tests.el: Fix requires. (buffer-tests-inhibit-buffer-hooks): New test.
* | Remove some unused process.c variablesLars Ingebrigtsen2020-12-121-5/+0
| | | | | | | | | | * src/process.c (wait_reading_process_output): Remove some variables that are unused after the previous patch.
* | * src/keyboard.c: Fix bug#5803.Stefan Monnier2020-12-121-38/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A long time ago, `read_key_sequence` used to read the keymaps at the start, so if something happened between this start and the moment the user actually hits a key, `read_key_sequence` could end up using the wrong keymaps. To work around this problem, the code used `record_asynch_buffer_change` to try and trigger `read_key_sequence` to re-read the keymaps in some known cases. Several years ago, `read_key_sequence` was changed so as to read the keymaps only once the user hits a key, making this machinery now redundant (and also harmful apparently in bug#5803 because it introduces "spurious" events). So we here remove `record_asynch_buffer_change` and the `BUFFER_SWITCH_EVENT` and `Qbuffer_switch` pseudo-events it generated. * src/termhooks.h (enum event_kind): Delete `BUFFER_SWITCH_EVENT`. * src/keyboard.c: (record_asynch_buffer_change): Delete function. (syms_of_keyboard): Delete `Qbuffer_switch`. (force_auto_save_soon, readable_events) (kbd_buffer_store_buffered_event, kbd_buffer_get_event) (make_lispy_event): * src/xterm.c (handle_one_xevent): * src/w32term.c (w32_read_socket): * src/process.c (wait_reading_process_output) (read_and_dispose_of_process_output, exec_sentinel): Simplify accordingly.
* | Work around glib messing with signal handlers more than it shouldAkira Kyle2020-11-141-5/+21
| | | | | | | | | | | | | | * src/process.c (init_process_emacs): force glib's g_unix_signal handler into lib_child_handler where it should belong. Copyright-paperwork-exempt: yes
* | Tweak updating the process mark in set-process-bufferLars Ingebrigtsen2020-09-251-2/+5
| | | | | | | | | | * src/process.c (Fset_process_buffer): Only update the process mark if we actually change the buffer.
* | Make set-process-buffer also update the process markLars Ingebrigtsen2020-09-241-9/+11
| | | | | | | | | | * src/process.c (Fset_process_buffer): Update the process mark (bug#43573).
* | Refactor process mark settingLars Ingebrigtsen2020-09-241-18/+14
| | | | | | | | | | | | * src/process.c (update_process_mark): Make into its own function. (Fmake_process, Fmake_pipe_process, Fmake_serial_process) (connect_network_socket): Use it.
* | Don't retry reading after receiving EINVALPip Cet2020-09-141-1/+3
| | | | | | | | | | * src/process.c (wait_reading_process_output): Don't retry reading from an fd after an unknown error (bug#6074).
* | Mention `exec-path' in some process related doc stringsLars Ingebrigtsen2020-08-211-1/+4
| | | | | | | | | | | | | | * src/callproc.c (Fcall_process_region): (Fcall_process): * src/process.c (Fmake_process): Mention `exec-path' in the doc strings (bug#42704).
* | Fix problem where TLS connections would sometimes hangDerek Zhou2020-08-031-51/+46
| | | | | | | | | | | | | | | | | | | | * src/process.c (wait_reading_process_output): Before the select, check every interesting gnutls stream for available data in the buffer. If some of them hit, and either there is no wait_proc or the wait_proc is one of the gnutls streams with new data, set the select timeout to 0 after the select, and merge the gnutls buffer status into the select returns (bug#40665). This fixes a problem where TLS connections would sometimes hang.
* | Improve integer range checkingPaul Eggert2020-04-051-9/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/bignum.c (check_integer_range, check_uinteger_max) (check_int_nonnegative): New functions. * src/frame.c (check_frame_pixels): New function. (Fset_frame_height, Fset_frame_width, Fset_frame_size): Use it. * src/lisp.h (CHECK_RANGED_INTEGER, CHECK_TYPE_RANGED_INTEGER): Remove these macros. Unless otherwise specified, all callers replaced by calls to check_integer_range, check_uinteger_range, check_int_nonnegative. * src/frame.c (gui_set_right_divider_width) (gui_set_bottom_divider_width): * src/nsfns.m (ns_set_internal_border_width): * src/xfns.c (x_set_internal_border_width): Using check_int_nonnegative means these functions no longer incorrectly reject negative bignums; they treat them as 0, just like negative fixnums.
* | Make make-{network,serial}-process handle :coding nil consistentlyRobert Pluim2020-04-031-10/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The handling of :coding nil was different between make-{network,serial}-process and make-{pipe}process. Now they all handle :coding nil as if :coding had not been specified. * process.c (Fmake_serial_process) (set_network_socket_coding_system): Use plist-get to check if :coding has been specified instead of plist-member, to ensure that ":coding nil" does not override coding-system-for-{read,write}. * network-stream-tests.el (check-network-process-coding-system-bind) (check-network-process-coding-system-no-override) (check-network-process-coding-system-override): New tests. * etc/NEWS: Describe change in make-network-process and make-serial-process :coding behavior.
* | Add a module function to open a file descriptor connected to a pipe.Philipp Stephani2020-03-261-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A common complaint about the module API is that modules can't communicate asynchronously with Emacs. While it isn't possible to call arbitrary Emacs functions asynchronously, writing to a pipe should always be fine and is a pretty low-hanging fruit. This patch implements a function that adapts an existing pipe process. That way, users can use familiar tools like process filters or 'accept-process-output'. * src/module-env-28.h: Add 'open_channel' module function. * src/emacs-module.c (module_open_channel): Provide definition for 'open_channel'. (initialize_environment): Use it. * src/process.c (open_channel_for_module): New helper function. (syms_of_process): Define necessary symbol. * test/src/emacs-module-tests.el (module/async-pipe): New unit test. * test/data/emacs-module/mod-test.c (signal_system_error): New helper function. (signal_errno): Use it. (write_to_pipe): New function running in the background. (Fmod_test_async_pipe): New test module function. (emacs_module_init): Export it. * doc/lispref/internals.texi (Module Misc): Document new module function. * doc/lispref/processes.texi (Asynchronous Processes): New anchor for pipe processes. * etc/NEWS: Document 'open_channel' function.