diff options
| author | Richard M. Stallman | 1994-03-22 20:17:17 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-03-22 20:17:17 +0000 |
| commit | 6b6e798bb363882ac2aa1f91255ade8574977a38 (patch) | |
| tree | 337dec5f002b6d08478833a10c2a4ac2653e881c /src | |
| parent | b01150e7ca249aa187a4b0b8744bcb3a87ffd690 (diff) | |
| download | emacs-6b6e798bb363882ac2aa1f91255ade8574977a38.tar.gz emacs-6b6e798bb363882ac2aa1f91255ade8574977a38.zip | |
(Fcall_process): Make sure to close descriptors.
(call_process_cleanup): Always close descriptor.
Diffstat (limited to 'src')
| -rw-r--r-- | src/callproc.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/callproc.c b/src/callproc.c index 21d0f444a77..9b99e29f40a 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -127,8 +127,12 @@ call_process_cleanup (fdpid) | |||
| 127 | #else /* not MSDOS */ | 127 | #else /* not MSDOS */ |
| 128 | register int pid = XFASTINT (Fcdr (fdpid)); | 128 | register int pid = XFASTINT (Fcdr (fdpid)); |
| 129 | 129 | ||
| 130 | |||
| 130 | if (call_process_exited) | 131 | if (call_process_exited) |
| 131 | return Qnil; | 132 | { |
| 133 | close (XFASTINT (Fcar (fdpid))); | ||
| 134 | return Qnil; | ||
| 135 | } | ||
| 132 | 136 | ||
| 133 | if (EMACS_KILLPG (pid, SIGINT) == 0) | 137 | if (EMACS_KILLPG (pid, SIGINT) == 0) |
| 134 | { | 138 | { |
| @@ -330,6 +334,8 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") | |||
| 330 | synch_process_retcode = 0; | 334 | synch_process_retcode = 0; |
| 331 | 335 | ||
| 332 | #ifdef MSDOS /* MW, July 1993 */ | 336 | #ifdef MSDOS /* MW, July 1993 */ |
| 337 | /* ??? Someone who knows MSDOG needs to check whether this properly | ||
| 338 | closes all descriptors that it opens. */ | ||
| 333 | pid = run_msdos_command (new_argv, current_dir, filefd, outfilefd); | 339 | pid = run_msdos_command (new_argv, current_dir, filefd, outfilefd); |
| 334 | close (outfilefd); | 340 | close (outfilefd); |
| 335 | fd1 = -1; /* No harm in closing that one! */ | 341 | fd1 = -1; /* No harm in closing that one! */ |
| @@ -337,6 +343,7 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") | |||
| 337 | if (fd[0] < 0) | 343 | if (fd[0] < 0) |
| 338 | { | 344 | { |
| 339 | unlink (tempfile); | 345 | unlink (tempfile); |
| 346 | close (filefd); | ||
| 340 | report_file_error ("Cannot re-open temporary file", Qnil); | 347 | report_file_error ("Cannot re-open temporary file", Qnil); |
| 341 | } | 348 | } |
| 342 | #else /* not MSDOS */ | 349 | #else /* not MSDOS */ |
| @@ -355,15 +362,10 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") | |||
| 355 | } | 362 | } |
| 356 | #endif /* not MSDOS */ | 363 | #endif /* not MSDOS */ |
| 357 | 364 | ||
| 358 | #if 0 | ||
| 359 | /* Tell SIGCHLD handler to look for this pid. */ | ||
| 360 | synch_process_pid = pid; | ||
| 361 | /* Now let SIGCHLD come through. */ | ||
| 362 | sigsetmask (mask); | ||
| 363 | #endif | ||
| 364 | |||
| 365 | environ = save_environ; | 365 | environ = save_environ; |
| 366 | 366 | ||
| 367 | /* Close most of our fd's, but not fd[0] | ||
| 368 | since we will use that to read input from. */ | ||
| 367 | close (filefd); | 369 | close (filefd); |
| 368 | if (fd1 >= 0) | 370 | if (fd1 >= 0) |
| 369 | close (fd1); | 371 | close (fd1); |
| @@ -371,12 +373,15 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") | |||
| 371 | 373 | ||
| 372 | if (pid < 0) | 374 | if (pid < 0) |
| 373 | { | 375 | { |
| 374 | close (fd[0]); | 376 | if (fd[0] >= 0) |
| 377 | close (fd[0]); | ||
| 375 | report_file_error ("Doing vfork", Qnil); | 378 | report_file_error ("Doing vfork", Qnil); |
| 376 | } | 379 | } |
| 377 | 380 | ||
| 378 | if (XTYPE (buffer) == Lisp_Int) | 381 | if (XTYPE (buffer) == Lisp_Int) |
| 379 | { | 382 | { |
| 383 | if (fd[0] >= 0) | ||
| 384 | close (fd[0]); | ||
| 380 | #ifndef subprocesses | 385 | #ifndef subprocesses |
| 381 | /* If Emacs has been built with asynchronous subprocess support, | 386 | /* If Emacs has been built with asynchronous subprocess support, |
| 382 | we don't need to do this, I think because it will then have | 387 | we don't need to do this, I think because it will then have |
| @@ -386,6 +391,7 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") | |||
| 386 | return Qnil; | 391 | return Qnil; |
| 387 | } | 392 | } |
| 388 | 393 | ||
| 394 | /* Enable sending signal if user quits below. */ | ||
| 389 | call_process_exited = 0; | 395 | call_process_exited = 0; |
| 390 | 396 | ||
| 391 | #ifdef MSDOS | 397 | #ifdef MSDOS |