diff options
| author | Karl Heuer | 1995-12-13 02:26:40 +0000 |
|---|---|---|
| committer | Karl Heuer | 1995-12-13 02:26:40 +0000 |
| commit | 2610078a774e8b9349772a37d2267a3bb56d0321 (patch) | |
| tree | dcd7cdbeaaea9996228dbf2c6d37c8dc50e3c053 /src | |
| parent | 67d98d33afce21cbae01cf1a9ac43492b1e74049 (diff) | |
| download | emacs-2610078a774e8b9349772a37d2267a3bb56d0321.tar.gz emacs-2610078a774e8b9349772a37d2267a3bb56d0321.zip | |
(Fcall_process) [MSDOS]: Support redirection of
stderr. Assign process exit code to `synch_process_retcode' and
error description to `synch_process_death'. Reset
`synch_process_alive' to zero when the sub-process exits.
Diffstat (limited to 'src')
| -rw-r--r-- | src/callproc.c | 52 |
1 files changed, 30 insertions, 22 deletions
diff --git a/src/callproc.c b/src/callproc.c index 6ea2fe0a76d..2efff15d348 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -324,12 +324,6 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") | |||
| 324 | } | 324 | } |
| 325 | 325 | ||
| 326 | #ifdef MSDOS /* MW, July 1993 */ | 326 | #ifdef MSDOS /* MW, July 1993 */ |
| 327 | /* These vars record information from process termination. | ||
| 328 | Clear them now before process can possibly terminate, | ||
| 329 | to avoid timing error if process terminates soon. */ | ||
| 330 | synch_process_death = 0; | ||
| 331 | synch_process_retcode = 0; | ||
| 332 | |||
| 333 | if ((outf = egetenv ("TMP")) || (outf = egetenv ("TEMP"))) | 327 | if ((outf = egetenv ("TMP")) || (outf = egetenv ("TEMP"))) |
| 334 | strcpy (tempfile = alloca (strlen (outf) + 20), outf); | 328 | strcpy (tempfile = alloca (strlen (outf) + 20), outf); |
| 335 | else | 329 | else |
| @@ -349,6 +343,7 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") | |||
| 349 | close (filefd); | 343 | close (filefd); |
| 350 | report_file_error ("Opening process output file", Fcons (tempfile, Qnil)); | 344 | report_file_error ("Opening process output file", Fcons (tempfile, Qnil)); |
| 351 | } | 345 | } |
| 346 | fd[1] = outfilefd; | ||
| 352 | #endif | 347 | #endif |
| 353 | 348 | ||
| 354 | if (INTEGERP (buffer)) | 349 | if (INTEGERP (buffer)) |
| @@ -388,21 +383,6 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") | |||
| 388 | synch_process_death = 0; | 383 | synch_process_death = 0; |
| 389 | synch_process_retcode = 0; | 384 | synch_process_retcode = 0; |
| 390 | 385 | ||
| 391 | #ifdef MSDOS /* MW, July 1993 */ | ||
| 392 | /* ??? Someone who knows MSDOG needs to check whether this properly | ||
| 393 | closes all descriptors that it opens. */ | ||
| 394 | pid = run_msdos_command (new_argv, current_dir, filefd, outfilefd); | ||
| 395 | close (outfilefd); | ||
| 396 | fd1 = -1; /* No harm in closing that one! */ | ||
| 397 | fd[0] = open (tempfile, NILP (Vbinary_process_output) ? O_TEXT : O_BINARY); | ||
| 398 | if (fd[0] < 0) | ||
| 399 | { | ||
| 400 | unlink (tempfile); | ||
| 401 | close (filefd); | ||
| 402 | report_file_error ("Cannot re-open temporary file", Qnil); | ||
| 403 | } | ||
| 404 | #else /* not MSDOS */ | ||
| 405 | |||
| 406 | if (NILP (error_file)) | 386 | if (NILP (error_file)) |
| 407 | fd_error = open (NULL_DEVICE, O_WRONLY); | 387 | fd_error = open (NULL_DEVICE, O_WRONLY); |
| 408 | else if (STRINGP (error_file)) | 388 | else if (STRINGP (error_file)) |
| @@ -424,7 +404,35 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") | |||
| 424 | close (fd1); | 404 | close (fd1); |
| 425 | report_file_error ("Cannot open", error_file); | 405 | report_file_error ("Cannot open", error_file); |
| 426 | } | 406 | } |
| 407 | #ifdef MSDOS /* MW, July 1993 */ | ||
| 408 | /* ??? Someone who knows MSDOG needs to check whether this properly | ||
| 409 | closes all descriptors that it opens. | ||
| 410 | |||
| 411 | Note that run_msdos_command() actually returns the child process | ||
| 412 | exit status, not its PID, so we assign it to `synch_process_retcode' | ||
| 413 | below. */ | ||
| 414 | pid = run_msdos_command (new_argv, current_dir, | ||
| 415 | filefd, outfilefd, fd_error); | ||
| 427 | 416 | ||
| 417 | /* Record that the synchronous process exited and note its | ||
| 418 | termination status. */ | ||
| 419 | synch_process_alive = 0; | ||
| 420 | synch_process_retcode = pid; | ||
| 421 | if (synch_process_retcode < 0) /* means it couldn't be exec'ed */ | ||
| 422 | synch_process_death = strerror(errno); | ||
| 423 | |||
| 424 | close (outfilefd); | ||
| 425 | if (fd_error != outfilefd) | ||
| 426 | close (fd_error); | ||
| 427 | fd1 = -1; /* No harm in closing that one! */ | ||
| 428 | fd[0] = open (tempfile, NILP (Vbinary_process_output) ? O_TEXT : O_BINARY); | ||
| 429 | if (fd[0] < 0) | ||
| 430 | { | ||
| 431 | unlink (tempfile); | ||
| 432 | close (filefd); | ||
| 433 | report_file_error ("Cannot re-open temporary file", Qnil); | ||
| 434 | } | ||
| 435 | #else /* not MSDOS */ | ||
| 428 | #ifdef WINDOWSNT | 436 | #ifdef WINDOWSNT |
| 429 | pid = child_setup (filefd, fd1, fd_error, new_argv, 0, current_dir); | 437 | pid = child_setup (filefd, fd1, fd_error, new_argv, 0, current_dir); |
| 430 | #else /* not WINDOWSNT */ | 438 | #else /* not WINDOWSNT */ |
| @@ -441,8 +449,8 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") | |||
| 441 | #endif /* USG */ | 449 | #endif /* USG */ |
| 442 | child_setup (filefd, fd1, fd_error, new_argv, 0, current_dir); | 450 | child_setup (filefd, fd1, fd_error, new_argv, 0, current_dir); |
| 443 | } | 451 | } |
| 444 | #endif /* not MSDOS */ | ||
| 445 | #endif /* not WINDOWSNT */ | 452 | #endif /* not WINDOWSNT */ |
| 453 | #endif /* not MSDOS */ | ||
| 446 | 454 | ||
| 447 | environ = save_environ; | 455 | environ = save_environ; |
| 448 | 456 | ||