diff options
| author | Richard M. Stallman | 1999-09-03 18:29:30 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1999-09-03 18:29:30 +0000 |
| commit | 052062e0d8e39f43bceb9747d8812781f0357b72 (patch) | |
| tree | c822da235abfd30cd468c0125175364e3c09a0c7 /src | |
| parent | 066d59b3d54ab4d2e1274841153f327c520fffab (diff) | |
| download | emacs-052062e0d8e39f43bceb9747d8812781f0357b72.tar.gz emacs-052062e0d8e39f43bceb9747d8812781f0357b72.zip | |
(call-process) [macintosh]: Call mac_run_command in
sysdep.c. The Mac code is modeled after the DOS code.
Diffstat (limited to 'src')
| -rw-r--r-- | src/callproc.c | 79 |
1 files changed, 74 insertions, 5 deletions
diff --git a/src/callproc.c b/src/callproc.c index 51a4f59e3c3..f17b4cc63af 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -140,17 +140,16 @@ Lisp_Object | |||
| 140 | call_process_cleanup (fdpid) | 140 | call_process_cleanup (fdpid) |
| 141 | Lisp_Object fdpid; | 141 | Lisp_Object fdpid; |
| 142 | { | 142 | { |
| 143 | #ifdef MSDOS | 143 | #if defined (MSDOS) || defined (macintosh) |
| 144 | /* for MSDOS fdpid is really (fd . tempfile) */ | 144 | /* for MSDOS fdpid is really (fd . tempfile) */ |
| 145 | register Lisp_Object file; | 145 | register Lisp_Object file; |
| 146 | file = Fcdr (fdpid); | 146 | file = Fcdr (fdpid); |
| 147 | close (XFASTINT (Fcar (fdpid))); | 147 | close (XFASTINT (Fcar (fdpid))); |
| 148 | if (strcmp (XSTRING (file)-> data, NULL_DEVICE) != 0) | 148 | if (strcmp (XSTRING (file)-> data, NULL_DEVICE) != 0) |
| 149 | unlink (XSTRING (file)->data); | 149 | unlink (XSTRING (file)->data); |
| 150 | #else /* not MSDOS */ | 150 | #else /* not MSDOS and not macintosh */ |
| 151 | register int pid = XFASTINT (Fcdr (fdpid)); | 151 | register int pid = XFASTINT (Fcdr (fdpid)); |
| 152 | 152 | ||
| 153 | |||
| 154 | if (call_process_exited) | 153 | if (call_process_exited) |
| 155 | { | 154 | { |
| 156 | close (XFASTINT (Fcar (fdpid))); | 155 | close (XFASTINT (Fcar (fdpid))); |
| @@ -217,6 +216,10 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") | |||
| 217 | char *outf, *tempfile; | 216 | char *outf, *tempfile; |
| 218 | int outfilefd; | 217 | int outfilefd; |
| 219 | #endif | 218 | #endif |
| 219 | #ifdef macintosh | ||
| 220 | char *tempfile; | ||
| 221 | int outfilefd; | ||
| 222 | #endif | ||
| 220 | #if 0 | 223 | #if 0 |
| 221 | int mask; | 224 | int mask; |
| 222 | #endif | 225 | #endif |
| @@ -438,13 +441,35 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") | |||
| 438 | fd[1] = outfilefd; | 441 | fd[1] = outfilefd; |
| 439 | #endif /* MSDOS */ | 442 | #endif /* MSDOS */ |
| 440 | 443 | ||
| 444 | #ifdef macintosh | ||
| 445 | /* Since we don't have pipes on the Mac, create a temporary file to | ||
| 446 | hold the output of the subprocess. */ | ||
| 447 | tempfile = (char *) alloca (STRING_BYTES (XSTRING (Vtemp_file_name_pattern)) + 1); | ||
| 448 | bcopy (XSTRING (Vtemp_file_name_pattern)->data, tempfile, | ||
| 449 | STRING_BYTES (XSTRING (Vtemp_file_name_pattern)) + 1); | ||
| 450 | |||
| 451 | mktemp (tempfile); | ||
| 452 | |||
| 453 | outfilefd = creat (tempfile, S_IREAD | S_IWRITE); | ||
| 454 | if (outfilefd < 0) | ||
| 455 | { | ||
| 456 | close (filefd); | ||
| 457 | report_file_error ("Opening process output file", | ||
| 458 | Fcons (build_string (tempfile), Qnil)); | ||
| 459 | } | ||
| 460 | fd[0] = filefd; | ||
| 461 | fd[1] = outfilefd; | ||
| 462 | #endif /* macintosh */ | ||
| 463 | |||
| 441 | if (INTEGERP (buffer)) | 464 | if (INTEGERP (buffer)) |
| 442 | fd[1] = open (NULL_DEVICE, O_WRONLY), fd[0] = -1; | 465 | fd[1] = open (NULL_DEVICE, O_WRONLY), fd[0] = -1; |
| 443 | else | 466 | else |
| 444 | { | 467 | { |
| 445 | #ifndef MSDOS | 468 | #ifndef MSDOS |
| 469 | #ifndef macintosh | ||
| 446 | pipe (fd); | 470 | pipe (fd); |
| 447 | #endif | 471 | #endif |
| 472 | #endif | ||
| 448 | #if 0 | 473 | #if 0 |
| 449 | /* Replaced by close_process_descs */ | 474 | /* Replaced by close_process_descs */ |
| 450 | set_exclusive_use (fd[0]); | 475 | set_exclusive_use (fd[0]); |
| @@ -502,6 +527,49 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") | |||
| 502 | 527 | ||
| 503 | current_dir = ENCODE_FILE (current_dir); | 528 | current_dir = ENCODE_FILE (current_dir); |
| 504 | 529 | ||
| 530 | #ifdef macintosh | ||
| 531 | { | ||
| 532 | /* Call run_mac_command in sysdep.c here directly instead of doing | ||
| 533 | a child_setup as for MSDOS and other platforms. Note that this | ||
| 534 | code does not handle passing the environment to the synchronous | ||
| 535 | Mac subprocess. */ | ||
| 536 | char *infn, *outfn, *errfn, *currdn; | ||
| 537 | |||
| 538 | /* close these files so subprocess can write to them */ | ||
| 539 | close (outfilefd); | ||
| 540 | if (fd_error != outfilefd) | ||
| 541 | close (fd_error); | ||
| 542 | fd1 = -1; /* No harm in closing that one! */ | ||
| 543 | |||
| 544 | infn = XSTRING (infile)->data; | ||
| 545 | outfn = tempfile; | ||
| 546 | if (NILP (error_file)) | ||
| 547 | errfn = NULL_DEVICE; | ||
| 548 | else if (EQ (Qt, error_file)) | ||
| 549 | errfn = outfn; | ||
| 550 | else | ||
| 551 | errfn = XSTRING (error_file)->data; | ||
| 552 | currdn = XSTRING (current_dir)->data; | ||
| 553 | pid = run_mac_command (new_argv, currdn, infn, outfn, errfn); | ||
| 554 | |||
| 555 | /* Record that the synchronous process exited and note its | ||
| 556 | termination status. */ | ||
| 557 | synch_process_alive = 0; | ||
| 558 | synch_process_retcode = pid; | ||
| 559 | if (synch_process_retcode < 0) /* means it couldn't be exec'ed */ | ||
| 560 | synch_process_death = strerror (errno); | ||
| 561 | |||
| 562 | /* Since CRLF is converted to LF within `decode_coding', we can | ||
| 563 | always open a file with binary mode. */ | ||
| 564 | fd[0] = open (tempfile, O_BINARY); | ||
| 565 | if (fd[0] < 0) | ||
| 566 | { | ||
| 567 | unlink (tempfile); | ||
| 568 | close (filefd); | ||
| 569 | report_file_error ("Cannot re-open temporary file", Qnil); | ||
| 570 | } | ||
| 571 | } | ||
| 572 | #else /* not macintosh */ | ||
| 505 | #ifdef MSDOS /* MW, July 1993 */ | 573 | #ifdef MSDOS /* MW, July 1993 */ |
| 506 | /* Note that on MSDOS `child_setup' actually returns the child process | 574 | /* Note that on MSDOS `child_setup' actually returns the child process |
| 507 | exit status, not its PID, so we assign it to `synch_process_retcode' | 575 | exit status, not its PID, so we assign it to `synch_process_retcode' |
| @@ -557,6 +625,7 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") | |||
| 557 | if (fd_error >= 0) | 625 | if (fd_error >= 0) |
| 558 | close (fd_error); | 626 | close (fd_error); |
| 559 | #endif /* not MSDOS */ | 627 | #endif /* not MSDOS */ |
| 628 | #endif /* not macintosh */ | ||
| 560 | 629 | ||
| 561 | environ = save_environ; | 630 | environ = save_environ; |
| 562 | 631 | ||
| @@ -590,14 +659,14 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") | |||
| 590 | /* Enable sending signal if user quits below. */ | 659 | /* Enable sending signal if user quits below. */ |
| 591 | call_process_exited = 0; | 660 | call_process_exited = 0; |
| 592 | 661 | ||
| 593 | #ifdef MSDOS | 662 | #if defined(MSDOS) || defined(macintosh) |
| 594 | /* MSDOS needs different cleanup information. */ | 663 | /* MSDOS needs different cleanup information. */ |
| 595 | record_unwind_protect (call_process_cleanup, | 664 | record_unwind_protect (call_process_cleanup, |
| 596 | Fcons (make_number (fd[0]), build_string (tempfile))); | 665 | Fcons (make_number (fd[0]), build_string (tempfile))); |
| 597 | #else | 666 | #else |
| 598 | record_unwind_protect (call_process_cleanup, | 667 | record_unwind_protect (call_process_cleanup, |
| 599 | Fcons (make_number (fd[0]), make_number (pid))); | 668 | Fcons (make_number (fd[0]), make_number (pid))); |
| 600 | #endif /* not MSDOS */ | 669 | #endif /* not MSDOS and not macintosh */ |
| 601 | 670 | ||
| 602 | 671 | ||
| 603 | if (BUFFERP (buffer)) | 672 | if (BUFFERP (buffer)) |