1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-05 22:20:24 -08:00

Make sure 'make-process' locks the process to the current thread

* src/process.c (set_proc_thread): New function.
(Fset_process_thread, create_process): Use it.
This commit is contained in:
Eli Zaretskii 2025-08-16 13:01:01 +03:00
parent 37325ed5a9
commit c93be71e45

View file

@ -1446,6 +1446,18 @@ See `set-process-sentinel' for more info on sentinels. */)
return XPROCESS (process)->sentinel;
}
static void
set_proc_thread (struct Lisp_Process *proc, struct thread_state *thrd)
{
eassert (THREADP (proc->thread) && XTHREAD (proc->thread) == thrd);
eassert (proc->infd < FD_SETSIZE);
if (proc->infd >= 0)
fd_callback_info[proc->infd].thread = thrd;
eassert (proc->outfd < FD_SETSIZE);
if (proc->outfd >= 0)
fd_callback_info[proc->outfd].thread = thrd;
}
DEFUN ("set-process-thread", Fset_process_thread, Sset_process_thread,
2, 2, 0,
doc: /* Set the locking thread of PROCESS to be THREAD.
@ -1466,12 +1478,7 @@ If THREAD is nil, the process is unlocked. */)
proc = XPROCESS (process);
pset_thread (proc, thread);
eassert (proc->infd < FD_SETSIZE);
if (proc->infd >= 0)
fd_callback_info[proc->infd].thread = tstate;
eassert (proc->outfd < FD_SETSIZE);
if (proc->outfd >= 0)
fd_callback_info[proc->outfd].thread = tstate;
set_proc_thread (proc, tstate);
return thread;
}
@ -2261,6 +2268,8 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
&& !EQ (p->filter, Qt))
add_process_read_fd (inchannel);
set_proc_thread (p, current_thread);
specpdl_ref count = SPECPDL_INDEX ();
/* This may signal an error. */