emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-29 1594d5f17ad: Fix setting the pipe capacity for subprocesses


From: Eli Zaretskii
Subject: emacs-29 1594d5f17ad: Fix setting the pipe capacity for subprocesses
Date: Fri, 6 Oct 2023 01:32:35 -0400 (EDT)

branch: emacs-29
commit 1594d5f17ad9845be526381e6cd62313da41590a
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Fix setting the pipe capacity for subprocesses
    
    * src/process.c (create_process) [F_SETPIPE_SZ]: Set the pipe
    capacity only if the required read-process-max is larger than the
    default capacity of the pipe.  (Bug#66288)
---
 src/process.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/process.c b/src/process.c
index 67d1d3e425f..5f7408a9395 100644
--- a/src/process.c
+++ b/src/process.c
@@ -2189,8 +2189,14 @@ create_process (Lisp_Object process, char **new_argv, 
Lisp_Object current_dir)
       inchannel = p->open_fd[READ_FROM_SUBPROCESS];
       forkout = p->open_fd[SUBPROCESS_STDOUT];
 
-#if defined(GNU_LINUX) && defined(F_SETPIPE_SZ)
-      fcntl (inchannel, F_SETPIPE_SZ, read_process_output_max);
+#if defined(F_SETPIPE_SZ) && defined(F_GETPIPE_SZ)
+      /* If they requested larger reads than the default system pipe
+         capacity, try enlarging the capacity to match the request.  */
+      if (read_process_output_max > fcntl (inchannel, F_GETPIPE_SZ))
+       {
+         int readmax = clip_to_bounds (1, read_process_output_max, INT_MAX);
+         fcntl (inchannel, F_SETPIPE_SZ, readmax);
+       }
 #endif
     }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]