aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Simplify remove_slash_colonPaul Eggert2017-08-281-1/+1
| | | | | * src/process.c (remove_slash_colon): Simplify and avoid a special case for "/:" by itself.
* Minor improvements for tramp-interrupt-process, documentationMichael Albinus2017-08-241-2/+2
| | | | | | | | | | | | | * doc/lispref/processes.texi (Signals to Processes): * etc/NEWS: Document interrupt-process-functions. * lisp/net/tramp.el (tramp-interrupt-process): Test also for `process-live-p'. * src/process.c (Vinterrupt_process_functions): Fix docstring. * test/lisp/net/tramp-tests.el (tramp-test28-interrupt-process): Extend test.
* Implement `interrupt-process-functions'Michael Albinus2017-08-211-3/+30
| | | | | | | | | | | | | | * lisp/net/tramp.el (tramp-interrupt-process): Rename from `tramp-advice-interrupt-process'. Adapt according to changed API. (top): Add it to `interrupt-process-functions'. * src/process.c (Finternal_default_interrupt_process): New defun. (Finterrupt_process): Change implementation, based on Vinterrupt_process_functions. (Vinterrupt_process_functions): New defvar. * test/lisp/net/tramp-tests.el (tramp-test40-unload): Do not test removal of advice.
* Add an optional testfn parameter to assocNicolas Petton2017-07-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | * src/fns.c (assoc): New optional testfn parameter used for comparison when provided. * test/src/fns-tests.el (test-assoc-testfn): Add tests for the new 'testfn' parameter. * src/buffer.c: * src/coding.c: * src/dbusbind.c: * src/font.c: * src/fontset.c: * src/gfilenotify.c: * src/image.c: * src/keymap.c: * src/process.c: * src/w32fns.c: * src/w32font.c: * src/w32notify.c: * src/w32term.c: * src/xdisp.c: * src/xfont.c: Add a third argument to Fassoc calls. * etc/NEWS: * doc/lispref/lists.texi: Document the new 'testfn' parameter.
* Fix threads on NS (bug#25265)Alan Third2017-07-011-7/+6
| | | | | | | | | | | | | src/nsterm.h (ns_select): Compiler doesn't like sigmask being const. (ns_run_loop_break) [HAVE_PTHREAD]: New function. src/nsterm.m (ns_select): Call thread_select from within ns_select. (ns_run_loop_break) [HAVE_PTHREAD]: New function. (ns_send_appdefined): Don't wait for main thread when sending app defined event. src/process.c (wait_reading_process_output): Call thread_select from within ns_select. src/systhread.c (sys_cond_broadcast) [HAVE_NS]: Break ns_select out of its event loop using ns_run_loop_break.
* Work around macOS bug in create_process, tooPaul Eggert2017-05-211-2/+7
| | | | | * src/process.c (create_process) [DARWIN_OS]: Reset SIGCHLD after vfork here, too.
* Avoid undefined behavior in struct sockaddrPaul Eggert2017-05-171-14/+17
| | | | | | | | | | Problem noted by Philipp Stephani in: http://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00391.html * src/conf_post.h (ATTRIBUTE_MAY_ALIAS, DECLARE_POINTER_ALIAS): New macros. * src/process.c (conv_sockaddr_to_lisp, conv_lisp_to_sockaddr) (connect_network_socket, network_interface_info) (server_accept_connection): Use it when aliasing non-char objects.
* Catch IPv4/IPv6 issues at compile timePaul Eggert2017-05-171-5/+5
| | | | | | * src/process.c (connect_network_socket): Use verify, not eassert, so that any problems are caught at compile-time. Avoid dodgy cast by using a local var of the correct type.
* Remove redundant code in connect_network_socketEli Zaretskii2017-05-171-22/+19
| | | | | | | | * src/process.c (connect_network_socket) [HAVE_GETSOCKNAME]: Remove redundant type-casting and variables. Don't call 'getsockname' to find the port for AF_LOCAL sockets. [AF_INET6]: Add an assertion to verify that the ports in the IPv4 and IPv6 structures are at the same offset and have the same size.
* Simplify procname code to avoid GCC bugPaul Eggert2017-05-161-29/+24
| | | | | | | | | * src/process.c (server_accept_connection): Simplify and avoid multiple calls and struct literals in the last case of a switch. The old code ran afoul of GCC bug 80659, which caused an internal compiler error. Problem reported by Jim Meyering in: http://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00182.html https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80659
* Fix address violation found by AddressSanitizerPaul Eggert2017-05-141-6/+22
| | | | | | | | | * src/process.c (connect_network_socket): Use struct sockaddr_storage, not struct sockaddr_in, to store info about a socket address. Problem reported by Philipp Stephani in: http://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00314.html This fix is based on a patch by Philipp in: http://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00357.html
* Use vfork if possible on Darwin (bug#26397)Alan Third2017-04-181-0/+9
| | | | | | | | | | | Co-authored-by: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> * src/conf_post.h (HAVE_WORKING_VFORK): Don't undef. (vfork): Don't define. * src/process.c (create_process) [DARWIN_OS]: Use fork if pty_flag is set, otherwise vfork. * src/callproc.c (call_process) [DARWIN_OS]: Use TIOCNOTTY to detach the controlling terminal instead of setsid.
* Fix assertion violations when displaying thread-related errorEli Zaretskii2017-04-171-2/+10
| | | | | * src/process.c (Faccept_process_output): Don't assume a thread's name is always a string.
* Use 'char *FOO' instead of 'char* FOO'Paul Eggert2017-02-181-1/+1
|
* Remove immediate_quit.Paul Eggert2017-02-011-9/+1
| | | | | | | | | The old code that sets and clears immediate_quit was ineffective except when Emacs is running in terminal mode, and has problematic race conditions anyway, so remove it. This will introduce some hangs when Emacs runs in terminal mode, and these hangs should be fixed in followup patches. * src/keyboard.c (immediate_quit): Remove. All uses removed.
* Replace QUIT with maybe_quitPaul Eggert2017-01-251-11/+11
| | | | | | | | There’s no longer need to have QUIT stand for a slug of C statements. Use the more-obvious function-call syntax instead. Also, use true and false when setting immediate_quit. These changes should not affect the generated machine code. * src/lisp.h (QUIT): Remove. All uses replaced by maybe_quit.
* Merge from origin/emacs-25Paul Eggert2017-01-011-1/+1
|\ | | | | | | | | 2e2a806 Fix copyright years by hand 5badc81 Update copyright year to 2017
| * Update copyright year to 2017Paul Eggert2016-12-311-1/+1
| | | | | | | | Run admin/update-copyright.
| * Port --enable-gcc-warnings to GCC 6.2.1Paul Eggert2016-10-121-25/+17
| | | | | | | | | | | | | | | | | | Backport from master. * src/conf_post.h (GNUC_PREREQ): New macro. * src/keyboard.c: Use it to work around GCC bug 54561. * src/process.c (would_block): New function. (server_accept_connection, wait_reading_process_output, send_process): Use it.
* | Don't call xg_select for a NextStep build.Ken Raeburn2016-12-301-2/+2
| | | | | | | | | | | | | | NextStep builds use glib but don't use xg_select. * src/process.c (wait_reading_process_output): Don't call xg_select for a NextStep build.
* | Attempt to fix crashes with threads in GTK buildsEli Zaretskii2016-12-301-5/+10
| | | | | | | | | | | | | | | | | | | | * src/xgselect.c (xg_select): Call pselect via thread_select, not directly, to avoid running Lisp (via unblock_input) when more than one thread could be running. (Bug#25247) * src/process.c (wait_reading_process_output) [HAVE_GLIB]: Call xg_select directly instead of through thread_select. * src/xgselect.h (xg_select): Last 2 arguments are no longer 'const', for consistency with thread_select.
* | ; Spelling fixesPaul Eggert2016-12-221-6/+5
| |
* | Fix commentsEli Zaretskii2016-12-171-2/+2
| | | | | | | | | | | | * src/thread.h (struct thread_state): Fix comments. * src/process.c (wait_reading_process_output): Fix a typo in commentary.
* | Support concurrency in Emacs LispEli Zaretskii2016-12-101-204/+343
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Merge branch 'test-concurrency' * src/thread.c: * src/thread.h: * src/systhread.c: * src/systhread.h: New files. * src/xgselect.c (xg_select): Avoid using SAFE_NALLOCA and use xnmalloc unconditionally. * src/window.c (struct save_window_data): Rename current_buffer to f_current_buffer. * src/w32proc.c (sys_select): Change the function signature to closer fit 'pselect' on Posix hosts. * src/search.c: * src/regex.h: Convert some globals to macros that reference thread-specific values. * src/process.c (pset_thread, add_non_keyboard_read_fd) (add_process_read_fd, add_non_blocking_write_fd) (recompute_input_desc, 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) (Fprocess_thread): New functions. (enum fd_bits): New enumeration. (fd_callback_data): Add 'thread' and 'waiting_thread', rename 'condition' to 'flags'. (set_process_filter_masks, create_process, create_pty) (Fmake_serial_process, finish_after_tls_connection) (connect_network_socket, deactivate_process) (server_accept_connection, wait_reading_process_output) (Fcontinue_process, Fstop_process, keyboard_bit_set) (add_timer_wait_descriptor, add_keyboard_wait_descriptor) (delete_keyboard_wait_descriptor): Use the new functions instead of manipulating fd flags and masks directly. (syms_of_process): Defsubr the new primitives. * src/print.c (print_object): Print threads, mutexes, and conditional variables. * src/lisp.h (enum pvec_type): New values PVEC_THREAD, PVEC_MUTEX, and PVEC_CONDVAR. (XTHREAD, XMUTEX, XCONDVAR, THREADP, MUTEXP, CONDVARP) (CHECK_THREAD, CHECK_MUTEX, CHECK_CONDVAR): New inline functions. (XSETTHREAD, XSETMUTEX, XSETCONDVAR): New macros. (struct handler): Add back byte_stack. Rename lisp_eval_depth to f_lisp_eval_depth. * src/eval.c (specpdl_kind, specpdl_arg, do_specbind) (rebind_for_thread_switch, do_one_unbind) (unbind_for_thread_switch): New functions. (init_eval): 'handlerlist' is not malloc'ed. (specbind): Call do_specbind. (unbind_to): Call do_one_unbind. (mark_specpdl): Accept 2 arguments. (mark_specpdl): Mark the saved value in a let-binding. * src/emacs.c (main): Call init_threads_once, init_threads, and syms_of_threads. * src/data.c (Ftype_of): Support thread, mutex, and condvar objects. (Fthreadp, Fmutexp, Fcondition_variable_p): New functions. (syms_of_data): DEFSYM and defsubr new symbols and primitives. * src/bytecode.c (struct byte_stack, FETCH, CHECK_RANGE) (BYTE_CODE_QUIT): Add back. (exec_byte_code): Add back byte stack manipulation. * src/alloc.c (cleanup_vector): Handle threads, mutexes, and conditional variables. (mark_stack): Now extern; accept additional argument 'bottom'. (flush_stack_call_func): New function. (garbage_collect_1): Call mark_threads and unmark_threads. Don't mark handlers. * src/.gdbinit (xbytecode): Add back. * test/src/thread-tests.el: New tests. * test/src/data-tests.el (binding-test-manual) (binding-test-setq-default, binding-test-makunbound) (binding-test-defvar-bool, binding-test-defvar-int) (binding-test-set-constant-t, binding-test-set-constant-nil) (binding-test-set-constant-keyword) (binding-test-set-constant-nil): New tests. * doc/lispref/processes.texi (Processes and Threads): New subsection. * doc/lispref/threads.texi: New file * doc/lispref/elisp.texi (Top): Include it. * doc/lispref/objects.texi (Thread Type, Mutex Type) (Condition Variable Type): New subsections. (Type Predicates): Add thread-related predicates. * doc/lispref/objects.texi (Editing Types): * doc/lispref/elisp.texi (Top): Update higher-level menus. * etc/NEWS: Mention concurrency features.
| * | Fix compilation warnings due to prototype of thread_selectEli Zaretskii2016-12-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | * src/thread.h <int select_func>: Make the 5th and 6th arguments be 'const'. * src/process.c [WINDOWSNT]: * src/w32proc.c: Make the 5th and 6th argument to sys_select be 'const'.
| * | Fix network streams.Eli Zaretskii2016-12-071-17/+24
| | | | | | | | | | | | | | | The original code messed up flags in fd_callback_data[], and also didn't call add_process_read_fd for process-related file descriptors.
| * | Fix compilation problems.Eli Zaretskii2016-12-051-8/+3
| | |
| * | Fix merged code in process.c and eval.c.Eli Zaretskii2016-12-051-5/+8
| | |
| * | Merge branch 'concurrency'Eli Zaretskii2016-12-041-204/+338
| |\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts (resolved): configure.ac src/Makefile.in src/alloc.c src/bytecode.c src/emacs.c src/eval.c src/lisp.h src/process.c src/regex.c src/regex.h
| | * | Fix the MS-Windows buildEli Zaretskii2015-11-021-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/thread.h [WINDOWSNT]: Include sys/socket.h. * src/sysselect.h: Don't define fd_set and FD_* macros for MS-Windows here. * src/w32.h: Define them here. * src/process.h (sys_select): Declare prototype. * src/sysdep.c: * src/process.c: * src/filelock.c: * src/emacs.c: * src/callproc.c: Move inclusion of sys/select.h after lisp.h. * nt/inc/socket.h: Include w32.h instead of sysselect.h
| | * | merge from trunkKen Raeburn2015-11-011-764/+1098
| | |\ \
| | * | | Improve MS-Windows implementation of threads.Eli Zaretskii2013-08-311-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | src/systhread.c (sys_cond_init): Set the 'initialized' member to true only if initialization is successful. Initialize wait_count and wait_count_lock. (sys_cond_wait, sys_cond_signal, sys_cond_broadcast): If 'initialized' is false, do nothing. (sys_cond_wait): Fix the implementation to avoid the "missed wakeup" bug: count the waiting threads, and reset the broadcast event once the last thread was released. (sys_cond_signal, sys_cond_broadcast): Use SetEvent instead of PulseEvent. Don't signal the event if no threads are waiting. (sys_cond_destroy): Only close non-NULL handles. (sys_thread_create): Return zero if unsuccessful, 1 if successful. src/systhread.h (w32thread_cond_t): New member 'initialized'. Rename waiters_count and waiters_count_lock to wait_count and wait_count_lock, respectively.
| | * | | Fix MS-Windows build.Eli Zaretskii2013-08-261-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | src/callproc.c: src/emacs.c: src/filelock.c: src/process.c: src/sysdep.c: src/w32.c: Reshuffle Windows-specific headers to avoid errors with redefinition of fd_set etc. src/process.c: Don't use num_pending_connects when NON_BLOCKING_CONNECT is not defined. src/sysselect.h: Move definitions of FD_* macros and of SELECT_TYPE here from w32.h. src/w32proc.c (sys_select): Adjust the argument types to what thread.h expects. nt/inc/sys/socket.h: Include stdint.h. Include sysselect.h instead of w32.h.
| | * | | merge from trunkTom Tromey2013-08-251-44/+28
| | |\ \ \
| | * | | | fix up some merge errors in process.cTom Tromey2013-08-191-17/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | remove a dead function clean up a fixme I added in create_pty during the merge
| | * | | | merge from trunkTom Tromey2013-08-191-121/+168
| | |\ \ \ \
| | * \ \ \ \ merge from trunkTom Tromey2013-07-261-138/+95
| | |\ \ \ \ \
| | * \ \ \ \ \ Merge from trunkTom Tromey2013-07-121-96/+61
| | |\ \ \ \ \ \
| | * \ \ \ \ \ \ merge from trunkTom Tromey2013-07-061-33/+66
| | |\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | this merges frmo trunk and fixes various build issues. this needed a few ugly tweaks. this hangs in "make check" now
| | * \ \ \ \ \ \ \ merge from trunkTom Tromey2013-06-131-7/+26
| | |\ \ \ \ \ \ \ \
| | * \ \ \ \ \ \ \ \ merge from trunk; clean up some issuesTom Tromey2013-06-031-240/+262
| | |\ \ \ \ \ \ \ \ \
| | * | | | | | | | | | fix process bugsTom Tromey2013-03-171-68/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix some process-related bugs, mostly thinkos from the conversion to recording fd state as flags. This now passes the test suite without hanging.
| | * | | | | | | | | | merge from trunkTom Tromey2013-03-081-46/+44
| | |\ \ \ \ \ \ \ \ \ \
| | * \ \ \ \ \ \ \ \ \ \ merge from trunkTom Tromey2013-01-051-17/+11
| | |\ \ \ \ \ \ \ \ \ \ \
| | * | | | | | | | | | | | Remove bit accidentally left over from the mergeTom Tromey2012-12-171-4/+0
| | | | | | | | | | | | | |
| | * | | | | | | | | | | | merge from trunkTom Tromey2012-12-171-767/+423
| | |\ \ \ \ \ \ \ \ \ \ \ \
| | * \ \ \ \ \ \ \ \ \ \ \ \ merge from trunkTom Tromey2012-09-041-29/+18
| | |\ \ \ \ \ \ \ \ \ \ \ \ \
| | * \ \ \ \ \ \ \ \ \ \ \ \ \ Merge from trunkTom Tromey2012-08-201-108/+194
| | |\ \ \ \ \ \ \ \ \ \ \ \ \ \
| | * | | | | | | | | | | | | | | process changesTom Tromey2012-08-151-28/+147
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changes wait_reading_process_output to handle threads better. It introduces a wrapper for select that releases the global lock, and it ensures that only a single thread can select a given file descriptor at a time. This also adds the thread-locking feature to processes. By default a process can only have its output accepted by the thread that created it. This can be changed using set-process-thread. (If the thread exits, the process is again available for waiting by any thread.) Note that thread-signal will not currently interrupt a thread blocked on select. I'll fix this later.
| | * | | | | | | | | | | | | | | Prepare process.c for threads by not having global select masks.Tom Tromey2012-08-151-130/+165
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The next step is to make it so selects can choose fds by thread.