X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fcallproc.c;h=8272ca99517fe73c5acacf113416331347afc9f3;hb=93b2c5b48a2d1fa8efe496032fbe888320161066;hp=ff28a498243fda0756cc74aec8a7a7e0662fcebe;hpb=21db8709c0c2dcedbd278c7fe571290d5ce80a71;p=chise%2Fxemacs-chise.git.1 diff --git a/src/callproc.c b/src/callproc.c index ff28a49..8272ca9 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -47,7 +47,9 @@ Boston, MA 02111-1307, USA. */ #include "systime.h" #include "sysproc.h" +#include "sysdir.h" #include "sysfile.h" /* Always include after sysproc.h */ +#include "sysdir.h" #include "syssignal.h" /* Always include before systty.h */ #include "systty.h" @@ -169,6 +171,8 @@ Arguments are The program's input comes from file INFILE (nil means `/dev/null'). Insert output in BUFFER before point; t means current buffer; nil for BUFFER means discard it; 0 means discard and don't wait. +If BUFFER is a string, then find or create a buffer with that name, +then insert the output in that buffer, before point. BUFFER can also have the form (REAL-BUFFER STDERR-FILE); in that case, REAL-BUFFER says what to do with standard output, as above, while STDERR-FILE says what to do with standard error in the child. @@ -288,7 +292,7 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you || ZEROP (buffer))) { Lisp_Object spec_buffer = buffer; - buffer = Fget_buffer (buffer); + buffer = Fget_buffer_create (buffer); /* Mention the buffer name for a better error message. */ if (NILP (buffer)) CHECK_BUFFER (spec_buffer); @@ -395,9 +399,6 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you } #endif } - /* Close STDERR into the parent process. We no longer need it. */ - if (fd_error >= 0) - close (fd_error); #else /* not WIN32_NATIVE */ pid = fork (); @@ -416,17 +417,18 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you child_setup (filefd, fd1, fd_error, new_argv, (char *) XSTRING_DATA (current_dir)); } - if (fd_error >= 0) - close (fd_error); - #endif /* not WIN32_NATIVE */ environ = save_environ; + /* Close STDERR into the parent process. We no longer need it. */ + if (fd_error >= 0) + close (fd_error); + /* Close most of our fd's, but not fd[0] since we will use that to read input from. */ close (filefd); - if (fd1 >= 0) + if ((fd1 >= 0) && (fd1 != fd_error)) close (fd1); } @@ -772,13 +774,14 @@ child_setup (int in, int out, int err, char **new_argv, close (out); close (err); - /* I can't think of any reason why child processes need any more - than the standard 3 file descriptors. It would be cleaner to + /* Close non-process-related file descriptors. It would be cleaner to close just the ones that need to be, but the following brute force approach is certainly effective, and not too slow. */ + { int fd; - for (fd=3; fd<=64; fd++) + + for (fd = 3; fd < MAXDESC; fd++) close (fd); } #endif /* not WIN32_NATIVE */