diff options
| author | Eli Zaretskii | 2025-08-16 13:01:01 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2025-08-16 13:01:01 +0300 |
| commit | c93be71e45d4cebeb017c813426228e579e9381d (patch) | |
| tree | d73c0a0d561c29b6b193407c3b1573a13a733576 | |
| parent | 37325ed5a9c7f62c35b368d9530496ed31404940 (diff) | |
| download | emacs-c93be71e45d4cebeb017c813426228e579e9381d.tar.gz emacs-c93be71e45d4cebeb017c813426228e579e9381d.zip | |
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.
| -rw-r--r-- | src/process.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/process.c b/src/process.c index ccad26b5339..f8d67561f26 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -1446,6 +1446,18 @@ See `set-process-sentinel' for more info on sentinels. */) | |||
| 1446 | return XPROCESS (process)->sentinel; | 1446 | return XPROCESS (process)->sentinel; |
| 1447 | } | 1447 | } |
| 1448 | 1448 | ||
| 1449 | static void | ||
| 1450 | set_proc_thread (struct Lisp_Process *proc, struct thread_state *thrd) | ||
| 1451 | { | ||
| 1452 | eassert (THREADP (proc->thread) && XTHREAD (proc->thread) == thrd); | ||
| 1453 | eassert (proc->infd < FD_SETSIZE); | ||
| 1454 | if (proc->infd >= 0) | ||
| 1455 | fd_callback_info[proc->infd].thread = thrd; | ||
| 1456 | eassert (proc->outfd < FD_SETSIZE); | ||
| 1457 | if (proc->outfd >= 0) | ||
| 1458 | fd_callback_info[proc->outfd].thread = thrd; | ||
| 1459 | } | ||
| 1460 | |||
| 1449 | DEFUN ("set-process-thread", Fset_process_thread, Sset_process_thread, | 1461 | DEFUN ("set-process-thread", Fset_process_thread, Sset_process_thread, |
| 1450 | 2, 2, 0, | 1462 | 2, 2, 0, |
| 1451 | doc: /* Set the locking thread of PROCESS to be THREAD. | 1463 | doc: /* Set the locking thread of PROCESS to be THREAD. |
| @@ -1466,12 +1478,7 @@ If THREAD is nil, the process is unlocked. */) | |||
| 1466 | 1478 | ||
| 1467 | proc = XPROCESS (process); | 1479 | proc = XPROCESS (process); |
| 1468 | pset_thread (proc, thread); | 1480 | pset_thread (proc, thread); |
| 1469 | eassert (proc->infd < FD_SETSIZE); | 1481 | set_proc_thread (proc, tstate); |
| 1470 | if (proc->infd >= 0) | ||
| 1471 | fd_callback_info[proc->infd].thread = tstate; | ||
| 1472 | eassert (proc->outfd < FD_SETSIZE); | ||
| 1473 | if (proc->outfd >= 0) | ||
| 1474 | fd_callback_info[proc->outfd].thread = tstate; | ||
| 1475 | 1482 | ||
| 1476 | return thread; | 1483 | return thread; |
| 1477 | } | 1484 | } |
| @@ -2261,6 +2268,8 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 2261 | && !EQ (p->filter, Qt)) | 2268 | && !EQ (p->filter, Qt)) |
| 2262 | add_process_read_fd (inchannel); | 2269 | add_process_read_fd (inchannel); |
| 2263 | 2270 | ||
| 2271 | set_proc_thread (p, current_thread); | ||
| 2272 | |||
| 2264 | specpdl_ref count = SPECPDL_INDEX (); | 2273 | specpdl_ref count = SPECPDL_INDEX (); |
| 2265 | 2274 | ||
| 2266 | /* This may signal an error. */ | 2275 | /* This may signal an error. */ |