aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2025-10-11Fix last changeEli Zaretskii1-0/+4
At least on MS-Windows, the last change caused the process-tests/fd-setsize-no-crash/make-process test to hang. * src/process.c (wait_reading_process_output) [WINDOWSNT]: Do not stop monitoring the process descriptor when zero bytes are read. The EOF indication from subprocesses on MS-Windows is detected via an error condition (see w32.c), while zero-size reads are not to be taken as such. (Bug#79436)
2025-10-11Stop monitoring fds after receiving EOFSpencer Baugh1-1/+1
When a subprocess closes its stdout/stderr pipe, that causes pselect to always indicate that fd is readable, and read to always return with EOF on that fd. Therefore when we receive an EOF we need to stop monitoring the fd. Otherwise Emacs will spin at 100% CPU, repeatedly reading that same EOF off the fd. * src/process.c (wait_reading_process_output): When 'read_process_output' returns EOF indication, stop monitoring the descriptor. (Bug#79436)
2025-10-11Allow creating a pipe process without a bufferSpencer Baugh1-5/+11
Previously, even passing :buffer nil to make-pipe-process would create a buffer. Now, if you explicitly call (make-pipe-process :buffer nil), it will create a pipe process without a buffer, just like all the other process creation functions. * src/process.c (Fmake_pipe_process): Check for explicit :buffer nil and don't make a buffer. (bug#79596) * doc/lispref/processes.texi (Asynchronous Processes): Update. * test/src/process-tests.el (process-test-make-pipe-process-no-buffer): Add test.
2025-09-27Use up-to-date time in wait_reading_process_outputPaul Eggert1-15/+6
In “Avoid duplicate calls to current_timespec” (2015-07-05) we started caching current_timespec results in NOW. However, this was buggy: we updated NOW only when the timeout was nonzero, but the timeout can be set temporarily to zero in several places in wait_reading_process_output (such as when checking for process status changes), which would cause us to never update NOW and therefore never detect that a timeout happened. Also, this caching was wrong even in principle: since we call Lisp code from wait_reading_process_output, substantial amounts of time can pass, and we can be left using an outdated NOW and incorrectly not time out. Also, nowadays we can use monotonic_coarse_timespec which is fast, and which is better anyway because it’s immune to manual clock changes. Co-authored-by: Spencer Baugh <sbaugh@janestreet.com> * src/process.c (wait_reading_process_output): Stop caching the current realtime. Instead, use the coarse monotonic clock without caching.
2025-09-20Improve documentation of 'accept-process-output'Eli Zaretskii1-2/+8
* doc/lispref/processes.texi (Accepting Output): * src/process.c (Faccept_process_output): Document better the meaning of the timeout of 'accept-process-output' a,d the fact that it doesn't always return as soon as some output is available. See https://lists.gnu.org/archive/html/emacs-devel/2025-08/msg00750.html for more details.
2025-09-06; * src/process.c (deactivate_process): Fix last change.Eli Zaretskii1-2/+5
2025-09-06Avoid assertion violations when starting client network processEli Zaretskii1-1/+5
* src/process.c (deactivate_process): Clear the callback info of descriptors we are closing. (Bug#79367)
2025-09-05Fix locking to threads of the client network processEli Zaretskii1-0/+15
* src/process.c (server_accept_connection): Make the client process be locked to the same thread as the parent server process, or unlocked if the server process was unlocked. (Bug#79367)
2025-08-27; Fix formattingRobert Pluim1-3/+3
* src/process.c (clear_fd_callback_data, delete_write_fd, delete_keyboard_wait_descriptor): Space before paren.
2025-08-16; * src/process.c (set_proc_thread): Fix assertion.Eli Zaretskii1-1/+2
2025-08-16Make sure 'make-process' locks the process to the current threadEli Zaretskii1-6/+15
* src/process.c (set_proc_thread): New function. (Fset_process_thread, create_process): Use it.
2025-08-16Zero fd_callback_info when deleting an fdSpencer Baugh1-12/+12
.waiting_thread and .thread could be left set to non-NULL values in a deleted fd_callback_info entry. These would never be cleared by e.g. clear_waiting_thread_info since that only clears fd_callback_info entries up to max_desc. Clear fd_callback_info entirely when deleting an entry. * src/process.c (clear_fd_callback_data): Add. (delete_write_fd, delete_keyboard_wait_descriptor): Call clear_fd_callback_data. (bug#79201) (delete_read_fd): Remove duplicated clearing code. (deactivate_process): Remove duplicate recompute_max_desc.
2025-02-10Set process-adaptive-read-buffering to nil by defaultStefan Kangas1-1/+1
* src/process.c (syms_of_process) <process-adaptive-read-buffering>: Set the default to nil. (Bug#75574)
2025-01-21Signal error when keyword/arg list is malformedRobert Pluim1-0/+6
* src/data.c (syms_of_data): Add Qmalformed_keyword_arg_list error symbol. * src/process.c (Fmake_process, Fmake_pipe_process) (Fserial_process_configure, Fmake_serial_process) (Fmake_network_process): Signal Qmalformed_keyword_arg_list when the argument list length is odd. * src/sound.c (parse_sound): Also here.. * src/w32fns.c (Fw32_notification_notify): ..and here. (Bug#75584)
2025-01-19Replace call[1-8] with callnStefan Kangas1-5/+5
Since the introduction of the 'calln' macro, the 'call1', 'call2', ..., 'call8' macros are just aliases for the former. This is slightly misleading and potentially unhelpful. The number of arguments N can also easily go out-of-synch with the used alias callN. There is no reason not to replace these aliases with using 'calln' directly. To reduce the risk for mistakes, the tool Coccinelle was used to make these changes. See <https://coccinelle.gitlabpages.inria.fr/website/>. * src/alloc.c, src/androidvfs.c, src/androidfns.c, src/buffer.c: * src/callint.c, src/callproc.c, src/casefiddle.c, src/charset.c: * src/chartab.c, src/cmds.c, src/coding.c, src/composite.c: * src/data.c, src/dbusbind.c, src/dired.c, src/doc.c: * src/emacs.c, src/eval.c, src/fileio.c, src/filelock.c: * src/fns.c, src/frame.c, src/gtkutil.c, src/haikufns.c: * src/haikumenu.c, src/image.c, src/insdel.c, src/intervals.c: * src/keyboard.c, src/keymap.c, src/lisp.h, src/lread.c: * src/minibuf.c, src/nsfns.m, src/nsselect.m, src/pgtkfns.c: * src/pgtkselect.c, src/print.c, src/process.c, src/sort.c: * src/syntax.c, src/textconv.c, src/textprop.c, src/undo.c: * src/w32fns.c, src/window.c, src/xfaces.c, src/xfns.c: * src/xmenu.c, src/xselect.c, src/xterm.c: Replace all uses of 'call1', 'call2', ..., 'call8' with 'calln'.
2025-01-02Update copyright year to 2025Stefan Kangas1-1/+1
Run "TZ=UTC0 admin/update-copyright".
2025-01-01Update copyright year to 2025Paul Eggert1-1/+1
Run "TZ=UTC0 admin/update-copyright".
2024-12-19Fix network test failure when using VPN clientRobert Pluim1-6/+14
When using certain VPN clients, the interface info returned by 'getifaddrs' does not have the address family filled in for the ifa_netmask component (this is allowed by the standard, since the value is not specified). The resulting address info causes network tests suite failures. Fix by copying the address family from the returned interface address. * src/process.c (network_interface_list): Copy the interface address sa_family to the netmask address. (Fnetwork_lookup_address_info): Fix test for non-IP addresses to properly account for IPv6. * test/src/process-tests.el (process-tests-check-bug-74907): New test, checks that 'network-interface-list' output is as expected. (Bug#74907)
2024-12-18Mention network-interface-list in network-interface-info docstringRobert Pluim1-1/+2
* src/process.c (Fnetwork_interface_info): Reference 'network-interface-list'.
2024-12-16; * src/process.c (Fnetwork_interface_list): Fix typo.Robert Pluim1-1/+1
2024-12-13Add support for TCP_NODELAY on network streamsEric Marsden1-0/+5
* src/process.c (socket_options): add entry for TCP_NODELAY. * lisp/emacs-lisp/bytecomp.el: add :nodelay to valid keywords for make-network-process compiler-macro. * doc/lispref/processes.texi: document :nodelay keyword argument to set-network-process-option and make-network-process. (Bug#74793)
2024-12-12Pure storage removal: Replace calls to removed functionsPip Cet1-2/+2
* src/alloc.c (string_bytes, pin_string, valid_lisp_object_p) (process_mark_stack, survives_gc_p, syms_of_alloc): * src/androidterm.c (android_term_init): Replace call to 'build_pure_c_string'. * src/buffer.c (init_buffer_once, syms_of_buffer): * src/bytecode.c (exec_byte_code): * src/callint.c (syms_of_callint): * src/callproc.c (syms_of_callproc): * src/category.c (Fdefine_category): * src/coding.c (syms_of_coding): * src/comp.c (Fcomp__compile_ctxt_to_file0) (maybe_defer_native_compilation, syms_of_comp): * src/data.c (Fsetcar, Fsetcdr, Fdefalias, Faset, syms_of_data): * src/dbusbind.c (syms_of_dbusbind): * src/doc.c (Fsnarf_documentation): * src/emacs-module.c (syms_of_module): * src/eval.c (Finternal__define_uninitialized_variable) (Fdefconst_1, define_error, syms_of_eval): * src/fileio.c (syms_of_fileio): * src/fns.c (Ffillarray, Fclear_string, check_mutable_hash_table): * src/fontset.c (syms_of_fontset): * src/frame.c (make_initial_frame): * src/haikufns.c (syms_of_haikufns): * src/intervals.c (create_root_interval): * src/keyboard.c (syms_of_keyboard): * src/keymap.c (Fmake_sparse_keymap, Fset_keymap_parent) (store_in_keymap, syms_of_keymap): * src/lisp.h: * src/lread.c (Fload, read0, intern_c_string_1, define_symbol) (Fintern, defsubr, syms_of_lread): * src/pdumper.c (Fdump_emacs_portable): * src/pgtkfns.c (syms_of_pgtkfns): * src/pgtkterm.c (syms_of_pgtkterm): * src/process.c (syms_of_process): * src/search.c (syms_of_search): * src/sqlite.c (syms_of_sqlite): * src/syntax.c (syms_of_syntax): * src/treesit.c (syms_of_treesit): * src/w32fns.c (syms_of_w32fns): * src/xdisp.c (syms_of_xdisp): * src/xfaces.c (syms_of_xfaces): * src/xfns.c (syms_of_xfns): * src/xftfont.c (syms_of_xftfont): * src/xterm.c (syms_of_xterm): Remove calls to 'PURE_P', 'CHECK_IMPURE', 'Fpurecopy', and replace calls to 'build_pure_c_string', 'pure_list', 'pure_listn', etc., by impure equivalents.
2024-12-12Unexec removal: Main partPip Cet1-39/+28
* configure.ac: Remove unexec-specific parts. (EMACS_CONFIG_FEATURES): Always report that we do not have the UNEXEC feature. (AC_ECHO): No longer display a line about the unexec feature. * lisp/loadup.el: * lisp/startup.el: Remove unexec-specific code. * src/Makefile.in (base_obj): Drop 'UNEXEC_OBJ'. * src/alloc.c (staticvec): Never initialize this variable. (BLOCK_ALIGN): Always allow large blocks. (mmap_lisp_allowed_p): Remove unexec-specific code. * src/buffer.c (init_buffer): * src/conf_post.h (ADDRESS_SANITIZER): * src/emacs.c (load_pdump, main): Remove unexec-specific code. (Fdump_emacs): Remove function. (syms_of_emacs): Remove 'Fdump_emacs'. * src/lastfile.c: Remove unexec-specific code. * src/lisp.h (gflags): Remove unexec-specific flags. (will_dump_p, will_bootstrap_p, will_dump_with_unexec_p) (dumped_with_unexec_p, definitely_will_not_unexec_p): Remove or adjust predicates. (SUBR_SECTION_ATTRIBUTE): Remove unexec-specific definition. * src/pdumper.c (Fdump_emacs_portable): Remove unexec-specific warning. * src/process.c (init_process_emacs): Remove !unexec condition * src/sysdep.c (maybe_disable_address_randomization): Adjust comment. (init_signals): * src/timefns.c (init_timefns): Remove unexec-specific code. * src/w32heap.c (report_temacs_memory_usage): Remove function. * src/w32heap.h: Adjust comment. * src/w32image.c (globals_of_w32image): Remove unexec-specific code.
2024-09-19Type-check argument to network-lookup-address-infoRobert Pluim1-0/+5
* src/process.c (Fnetwork_lookup_address_info): Check that the "name" argument is a string, and mention 'puny-encode-domain'. (Bug#73337)
2024-08-22Prefer static_assert to verifyStefan Kangas1-7/+6
Although static_assert is C11-specific, and Emacs remains on C99, it has been backported to older compilers by Gnulib. Gnulib has already changed to prefer static_assert, and we can do the same. * lib-src/asset-directory-tool.c (main_2): * src/alloc.c (BLOCK_ALIGN, aligned_alloc, lisp_align_malloc) (vectorlike_nbytes, allocate_pseudovector): * src/android.c (android_globalize_reference, android_set_dashes): * src/android.h: * src/androidfont.c (androidfont_draw, androidfont_text_extents): * src/androidvfs.c: * src/bidi.c (BIDI_CACHE_MAX_ELTS_PER_SLOT, bidi_find_bracket_pairs): * src/buffer.c (init_buffer_once): * src/casefiddle.c (do_casify_multibyte_string): * src/dispnew.c (scrolling_window, scrolling): * src/editfns.c (styled_format): * src/emacs-module.c (module_extract_big_integer): * src/fileio.c (Fdo_auto_save): * src/fns.c (next_almost_prime, hash_string): * src/fringe.c (init_fringe): * src/keyboard.h (kbd_buffer_store_event_hold): * src/keymap.c: * src/lisp.h (memclear, reduce_emacs_uint_to_hash_hash, modiff_incr): * src/lread.c (skip_lazy_string): * src/pdumper.c (dump_bignum, Fdump_emacs_portable) (dump_do_dump_relocation, pdumper_load): * src/process.c (make_process, Fmake_process, connect_network_socket): * src/regex-emacs.c: * src/sort.c (tim_sort): * src/sysdep.c (init_random, SSIZE_MAX): * src/thread.c: * src/timefns.c (trillion_factor): * src/unexelf.c: * src/xterm.c (x_send_scroll_bar_event): Prefer static_assert to Gnulib verify. Remove import of verify.h, except when used for other reasons.
2024-07-29Fix sporadic crashes and `select' failures in dumped imagesPo Lu1-9/+17
* src/process.c (init_process_emacs) [HAVE_UNEXEC]: Clear dumped values of child_signal_read_fd and child_signal_write_fd.
2024-07-16Make error messages adhere to our standardsStefan Kangas1-2/+2
* src/cygw32.c (chdir_to_default_directory): * src/fns.c (secure_hash): * src/keyboard.c (Finternal_handle_focus_in): * src/keymap.c (store_in_keymap): * src/pgtkfns.c (pgtk_set_scroll_bar_foreground) (pgtk_set_scroll_bar_background, Fx_export_frames) (Fpgtk_set_monitor_scale_factor, pgtk_get_defaults_value) (pgtk_set_defaults_value, Fpgtk_print_frames_dialog) (pgtk_get_monitor_scale_factor): * src/pgtkterm.c (pgtk_set_parent_frame): * src/process.c (network_interface_info, send_process): * src/w32.c (w32_read_registry): * src/w32fns.c (Fw32_read_registry): * src/window.c (Frecenter): * src/xfns.c (Fx_export_frames, Fx_print_frames_dialog) (x_set_mouse_color): Make 'error' message strings follow our guidelines. More specifically, they should not end in a period, and normally also be capitalized. See '(elisp) Programming Tips'.
2024-06-14; Update comments in a recent commitEli Zaretskii1-0/+1
* src/process.c (read_and_insert_process_output): * src/insdel.c (insert_from_gap): * src/coding.h (struct coding_system): Improve comments (bug#71525).
2024-06-14"Insert before markers" in read_and_insert_process_output properlyDmitry Gutov1-3/+4
* src/coding.c (setup_coding_system): Initialize it. (produce_chars, encode_coding, decode_coding_gap): Obey it in insert_from_gap calls. (encode_string_utf_8, decode_string_utf_8): Update the other calls to insert_from_gap to have one new argument (false). * src/coding.h: New field insert_before_markers. * src/decompress.c (Fzlib_decompress_region): Here too. * src/insdel.c (insert_from_gap): Accept new argument BEFORE_MARKERS (bug#71525) and pass it through to adjust_markers_for_insert. * src/lisp.h: Update prototype. * src/process.c (read_and_insert_process_output): Set process_coding->insert_before_markers instead of calling adjust_markers_for_insert.
2024-06-11read_and_insert_process_output: Insert before markersDmitry Gutov1-1/+4
* src/insdel.c (adjust_markers_for_insert): Make non-static. * src/lisp.h: Add declaration for it. * src/process.c (read_and_insert_process_output): Use it here. And also call insert_1_both with BEFORE_MARKERS=t, for compatibility with internal-default-process-filter (bug#66020).
2024-06-11; * src/process.c (read_and_dispose_of_process_output): Fix style.Eli Zaretskii1-4/+3
2024-06-11fast-read-process-output: Make saferDmitry Gutov1-15/+20
* src/process.c (read_process_output): Move the call to 'read_and_insert_process_output' from here. (read_and_dispose_of_process_output): To here (bug#66020). So that any Lisp code invoked through modification hook from the former function also benefit from safety guards like running_asynch_code, saved match data, inhibit_quot, etc.
2024-06-11read_process_output_set_last_coding_system: Extract, reuseDmitry Gutov1-39/+45
* src/process.c (read_process_output_set_last_coding_system): New function, extracted from read_and_dispose_of_process_output. (read_and_dispose_of_process_output): Update accordingly. (read_and_insert_process_output): Use it here instead of just transferring carryover (bug#66020, also mentioned in bug#71452).
2024-06-11read_and_insert_process_output: Call 'prepare_to_modify_buffer' firstDmitry Gutov1-0/+2
* src/process.c (read_and_insert_process_output): Call 'prepare_to_modify_buffer' before any insertions (bug#71452).
2024-06-11; * src/process.c (syms_of_process): Fix ommission.Po Lu1-1/+1
2024-06-10; * src/process.c (read_process_output): Check in missing hunk.Po Lu1-1/+1
2024-06-10Rename new variable in process.cPo Lu1-2/+2
* src/process.c (syms_of_process): Rename read_process_output_fast to fast_read_process_output.
2024-06-09Unbreak build with Clang 15 on macOS 14.5Stefan Kangas1-2/+2
* src/process.c (read_process_output): Use EQ for comparison. (syms_of_process): Properly set a DEFVAR_BOOL to 'true' instead of 'Qt'.
2024-06-09Fix a recent change in reading from sub-processesEli Zaretskii1-2/+2
* src/process.c (make_process): Move to here... (create_process): ...from here.
2024-06-09; Fix coding style of last changePo Lu1-13/+13
* src/process.c (read_and_insert_process_output) (read_and_dispose_of_process_output): Fix coding style.
2024-06-09read-process-output-max: Increase the default valueDmitry Gutov1-1/+1
* src/process.c (read-process-output-max): Increase the default value to 65536 (bug#66020).
2024-06-09Remember the value of read_process_output_max when process is createdDmitry Gutov1-6/+5
* src/process.h (Lisp_Process): Add field readmax. * src/process.c (read_process_output): Use it. (create_process): Save the value of read_process_output_max to it when the process is created (bug#66020). Use for pipe size.
2024-06-09Go around calling the default process filter (reducing GC churn)Dmitry Gutov1-55/+143
Instead of allocating strings and passing them to the filter, pass the char buffer to a C function implementing the same logic. * src/process.c (read_process_output_before_insert) (read_process_output_after_insert): New functions, extracted from internal-default-process-filter. (Finternal_default_process_filter): Use them. (read_and_insert_process_output): New function. Use them. (read_process_output_fast): New variable. (read_process_output): Use it to choose how to insert (bug#66020). * etc/NEWS: Mention the change.
2024-05-14; * src/process.c (network_lookup_address_info_1): Quote functionRobert Pluim1-1/+1
2024-05-04Fix implementation of the --terminal command-line switchEli Zaretskii1-1/+1
It sounds like this has been broken ever since multi-tty was added to Emacs. * src/keyboard.c (dev_tty): New global variable. * src/keyboard.h: Declare 'dev_tty'. * src/emacs.c (main): Initialize 'dev_tty'. * src/term.c (Fcontrolling_tty_p, Fresume_tty, init_tty): * src/process.c (dissociate_controlling_tty): * src/keyboard.c (handle_interrupt_signal, handle_interrupt) (Fset_quit_char): Use 'dev_tty' instead of 'DEV_TTY'. (Bug#70519)
2024-03-10* src/keyboard.c (requeued_events_pending_p): Improve name and fix commentTim Ruffing1-4/+4
* src/keyboard.c, src/keyboard.h (requeued_events_pending_p): Rename to 'requeued_command_events_pending_p' to clarify that the function covers only command events. Fix wrong comment that claimed that the function was unused. * src/process.c (wait_reading_process_output): Update caller to use the new name.
2024-02-06Implement Lisp threading on AndroidPo Lu1-3/+30
Much like the NS port, only the main thread receives input from the user interface, which is fortunately not a major problem for packages such as lsp-mode that create Lisp threads. * configure.ac: Enable with_threads under Android. * src/android.c (android_init_events): Set `main_thread_id' to the ID of the main thread. (setEmacsParams): Set new global variable `android_jvm' to the JVM object, for the purpose of attaching Lisp threads to the JVM. (android_select): [THREADS_ENABLED]: If the caller isn't the main thread, resort to pselect. Don't check query before select returns. (android_check_query): Export. * src/android.h (_ANDROID_H_): Define new macro and update prototypes. * src/process.c (android_select_wrapper): New function. (wait_reading_process_output): If THREADS_ENABLED, call thread_select through the Android select wrapper. * src/thread.c (post_acquire_global_lock): Call android_check_query; replace android_java_env with the incoming Lisp thread's. (run_thread): Attach and detach the thread created to the JVM. (init_threads): Set the main thread's JNI environment object. * src/thread.h (struct thread_state) <java_env>: New field.
2024-01-02; Add 2024 to copyright yearsPo Lu1-1/+1
2023-12-10; Fix typosStefan Kangas1-1/+1
2023-11-30Document, that PROCESS of signal-process can be a stringMichael Albinus1-0/+2
* doc/lispref/processes.texi (Signals to Processes) [signal-process]: * src/process.c (Fsignal_process): Document, that PROCESS can be a string.