Mercurial > hg > xemacs-beta
comparison src/callproc.c @ 442:abe6d1db359e r21-2-36
Import from CVS: tag r21-2-36
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:35:02 +0200 |
parents | 8de8e3f6228a |
children | 576fb035e263 |
comparison
equal
deleted
inserted
replaced
441:72a7cfa4a488 | 442:abe6d1db359e |
---|---|
39 #include "sysproc.h" | 39 #include "sysproc.h" |
40 #include "sysfile.h" /* Always include after sysproc.h */ | 40 #include "sysfile.h" /* Always include after sysproc.h */ |
41 #include "syssignal.h" /* Always include before systty.h */ | 41 #include "syssignal.h" /* Always include before systty.h */ |
42 #include "systty.h" | 42 #include "systty.h" |
43 | 43 |
44 #ifdef WINDOWSNT | 44 #ifdef WIN32_NATIVE |
45 #define _P_NOWAIT 1 /* from process.h */ | 45 #define _P_NOWAIT 1 /* from process.h */ |
46 #include "nt.h" | 46 #include "nt.h" |
47 #endif | 47 #endif |
48 | 48 |
49 #ifdef DOS_NT | 49 #ifdef WIN32_NATIVE |
50 /* When we are starting external processes we need to know whether they | 50 /* When we are starting external processes we need to know whether they |
51 take binary input (no conversion) or text input (\n is converted to | 51 take binary input (no conversion) or text input (\n is converted to |
52 \r\n). Similarly for output: if newlines are written as \r\n then it's | 52 \r\n). Similarly for output: if newlines are written as \r\n then it's |
53 text process output, otherwise it's binary. */ | 53 text process output, otherwise it's binary. */ |
54 Lisp_Object Vbinary_process_input; | 54 Lisp_Object Vbinary_process_input; |
55 Lisp_Object Vbinary_process_output; | 55 Lisp_Object Vbinary_process_output; |
56 #endif /* DOS_NT */ | 56 #endif /* WIN32_NATIVE */ |
57 | 57 |
58 Lisp_Object Vshell_file_name; | 58 Lisp_Object Vshell_file_name; |
59 | 59 |
60 /* The environment to pass to all subprocesses when they are started. | 60 /* The environment to pass to all subprocesses when they are started. |
61 This is in the semi-bogus format of ("VAR=VAL" "VAR2=VAL2" ... ) | 61 This is in the semi-bogus format of ("VAR=VAL" "VAR2=VAL2" ... ) |
65 /* True iff we are about to fork off a synchronous process or if we | 65 /* True iff we are about to fork off a synchronous process or if we |
66 are waiting for it. */ | 66 are waiting for it. */ |
67 volatile int synch_process_alive; | 67 volatile int synch_process_alive; |
68 | 68 |
69 /* Nonzero => this is a string explaining death of synchronous subprocess. */ | 69 /* Nonzero => this is a string explaining death of synchronous subprocess. */ |
70 CONST char *synch_process_death; | 70 const char *synch_process_death; |
71 | 71 |
72 /* If synch_process_death is zero, | 72 /* If synch_process_death is zero, |
73 this is exit code of synchronous subprocess. */ | 73 this is exit code of synchronous subprocess. */ |
74 int synch_process_retcode; | 74 int synch_process_retcode; |
75 | 75 |
76 /* Clean up when exiting Fcall_process_internal. | 76 /* Clean up when exiting Fcall_process_internal. |
77 On MSDOS, delete the temporary file on any kind of termination. | 77 On Windows, delete the temporary file on any kind of termination. |
78 On Unix, kill the process and any children on termination by signal. */ | 78 On Unix, kill the process and any children on termination by signal. */ |
79 | 79 |
80 /* Nonzero if this is termination due to exit. */ | 80 /* Nonzero if this is termination due to exit. */ |
81 static int call_process_exited; | 81 static int call_process_exited; |
82 | 82 |
111 | 111 |
112 record_unwind_protect (call_process_kill, fdpid); | 112 record_unwind_protect (call_process_kill, fdpid); |
113 /* #### "c-G" -- need non-consing Single-key-description */ | 113 /* #### "c-G" -- need non-consing Single-key-description */ |
114 message ("Waiting for process to die...(type C-g again to kill it instantly)"); | 114 message ("Waiting for process to die...(type C-g again to kill it instantly)"); |
115 | 115 |
116 #ifdef WINDOWSNT | 116 #ifdef WIN32_NATIVE |
117 { | 117 { |
118 HANDLE pHandle = OpenProcess (PROCESS_ALL_ACCESS, 0, pid); | 118 HANDLE pHandle = OpenProcess (PROCESS_ALL_ACCESS, 0, pid); |
119 if (pHandle == NULL) | 119 if (pHandle == NULL) |
120 warn_when_safe (Qprocess, Qwarning, | 120 warn_when_safe (Qprocess, Qwarning, |
121 "cannot open process (PID %d) for cleanup", pid); | 121 "cannot open process (PID %d) for cleanup", pid); |
150 /* terminate this branch of the fork, without closing stdin/out/etc. */ | 150 /* terminate this branch of the fork, without closing stdin/out/etc. */ |
151 _exit (1); | 151 _exit (1); |
152 } | 152 } |
153 #endif /* unused */ | 153 #endif /* unused */ |
154 | 154 |
155 DEFUN ("call-process-internal", Fcall_process_internal, 1, MANY, 0, /* | 155 DEFUN ("old-call-process-internal", Fold_call_process_internal, 1, MANY, 0, /* |
156 Call PROGRAM synchronously in separate process, with coding-system specified. | 156 Call PROGRAM synchronously in separate process, with coding-system specified. |
157 Arguments are | 157 Arguments are |
158 (PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS). | 158 (PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS). |
159 The program's input comes from file INFILE (nil means `/dev/null'). | 159 The program's input comes from file INFILE (nil means `/dev/null'). |
160 Insert output in BUFFER before point; t means current buffer; | 160 Insert output in BUFFER before point; t means current buffer; |
178 { | 178 { |
179 /* This function can GC */ | 179 /* This function can GC */ |
180 Lisp_Object infile, buffer, current_dir, display, path; | 180 Lisp_Object infile, buffer, current_dir, display, path; |
181 int fd[2]; | 181 int fd[2]; |
182 int filefd; | 182 int filefd; |
183 #ifdef WINDOWSNT | 183 #ifdef WIN32_NATIVE |
184 HANDLE pHandle; | 184 HANDLE pHandle; |
185 #endif | 185 #endif |
186 int pid; | 186 int pid; |
187 char buf[16384]; | 187 char buf[16384]; |
188 char *bufptr = buf; | 188 char *bufptr = buf; |
189 int bufsize = 16384; | 189 int bufsize = 16384; |
190 int speccount = specpdl_depth (); | 190 int speccount = specpdl_depth (); |
191 struct gcpro gcpro1, gcpro2; | 191 struct gcpro gcpro1, gcpro2, gcpro3; |
192 char **new_argv = alloca_array (char *, max (2, nargs - 2)); | 192 char **new_argv = alloca_array (char *, max (2, nargs - 2)); |
193 | 193 |
194 /* File to use for stderr in the child. | 194 /* File to use for stderr in the child. |
195 t means use same as standard output. */ | 195 t means use same as standard output. */ |
196 Lisp_Object error_file; | 196 Lisp_Object error_file; |
233 Fcons (current_buffer->directory, Qnil)); | 233 Fcons (current_buffer->directory, Qnil)); |
234 #endif /* 0 */ | 234 #endif /* 0 */ |
235 NUNGCPRO; | 235 NUNGCPRO; |
236 } | 236 } |
237 | 237 |
238 GCPRO1 (current_dir); | 238 GCPRO2 (current_dir, path); |
239 | 239 |
240 if (nargs >= 2 && ! NILP (args[1])) | 240 if (nargs >= 2 && ! NILP (args[1])) |
241 { | 241 { |
242 struct gcpro ngcpro1; | 242 struct gcpro ngcpro1; |
243 NGCPRO1 (current_buffer->directory); | 243 NGCPRO1 (current_buffer->directory); |
248 else | 248 else |
249 infile = build_string (NULL_DEVICE); | 249 infile = build_string (NULL_DEVICE); |
250 | 250 |
251 UNGCPRO; | 251 UNGCPRO; |
252 | 252 |
253 GCPRO2 (infile, current_dir); /* Fexpand_file_name might trash it */ | 253 GCPRO3 (infile, current_dir, path); /* Fexpand_file_name might trash it */ |
254 | 254 |
255 if (nargs >= 3) | 255 if (nargs >= 3) |
256 { | 256 { |
257 buffer = args[2]; | 257 buffer = args[2]; |
258 | 258 |
346 | 346 |
347 if (NILP (error_file)) | 347 if (NILP (error_file)) |
348 fd_error = open (NULL_DEVICE, O_WRONLY | OPEN_BINARY); | 348 fd_error = open (NULL_DEVICE, O_WRONLY | OPEN_BINARY); |
349 else if (STRINGP (error_file)) | 349 else if (STRINGP (error_file)) |
350 { | 350 { |
351 fd_error = open ((CONST char *) XSTRING_DATA (error_file), | 351 fd_error = open ((const char *) XSTRING_DATA (error_file), |
352 #ifdef DOS_NT | 352 #ifdef WIN32_NATIVE |
353 O_WRONLY | O_TRUNC | O_CREAT | O_TEXT, | 353 O_WRONLY | O_TRUNC | O_CREAT | O_TEXT, |
354 S_IREAD | S_IWRITE | 354 S_IREAD | S_IWRITE |
355 #else /* not DOS_NT */ | 355 #else /* not WIN32_NATIVE */ |
356 O_WRONLY | O_TRUNC | O_CREAT | OPEN_BINARY, | 356 O_WRONLY | O_TRUNC | O_CREAT | OPEN_BINARY, |
357 CREAT_MODE | 357 CREAT_MODE |
358 #endif /* not DOS_NT */ | 358 #endif /* not WIN32_NATIVE */ |
359 ); | 359 ); |
360 } | 360 } |
361 | 361 |
362 if (fd_error < 0) | 362 if (fd_error < 0) |
363 { | 363 { |
364 int save_errno = errno; | |
364 close (filefd); | 365 close (filefd); |
365 close (fd[0]); | 366 close (fd[0]); |
366 if (fd1 >= 0) | 367 if (fd1 >= 0) |
367 close (fd1); | 368 close (fd1); |
369 errno = save_errno; | |
368 report_file_error ("Cannot open", Fcons(error_file, Qnil)); | 370 report_file_error ("Cannot open", Fcons(error_file, Qnil)); |
369 } | 371 } |
370 | 372 |
371 fork_error = Qnil; | 373 fork_error = Qnil; |
372 #ifdef WINDOWSNT | 374 #ifdef WIN32_NATIVE |
373 pid = child_setup (filefd, fd1, fd_error, new_argv, | 375 pid = child_setup (filefd, fd1, fd_error, new_argv, |
374 (char *) XSTRING_DATA (current_dir)); | 376 (char *) XSTRING_DATA (current_dir)); |
375 if (!INTP (buffer)) | 377 if (!INTP (buffer)) |
376 { | 378 { |
377 /* OpenProcess() as soon after child_setup as possible. It's too | 379 /* OpenProcess() as soon after child_setup as possible. It's too |
387 #endif | 389 #endif |
388 } | 390 } |
389 /* Close STDERR into the parent process. We no longer need it. */ | 391 /* Close STDERR into the parent process. We no longer need it. */ |
390 if (fd_error >= 0) | 392 if (fd_error >= 0) |
391 close (fd_error); | 393 close (fd_error); |
392 #else /* not WINDOWSNT */ | 394 #else /* not WIN32_NATIVE */ |
393 pid = fork (); | 395 pid = fork (); |
394 | 396 |
395 if (pid == 0) | 397 if (pid == 0) |
396 { | 398 { |
397 if (fd[0] >= 0) | 399 if (fd[0] >= 0) |
408 (char *) XSTRING_DATA (current_dir)); | 410 (char *) XSTRING_DATA (current_dir)); |
409 } | 411 } |
410 if (fd_error >= 0) | 412 if (fd_error >= 0) |
411 close (fd_error); | 413 close (fd_error); |
412 | 414 |
413 #endif /* not WINDOWSNT */ | 415 #endif /* not WIN32_NATIVE */ |
414 | 416 |
415 environ = save_environ; | 417 environ = save_environ; |
416 | 418 |
417 /* Close most of our fd's, but not fd[0] | 419 /* Close most of our fd's, but not fd[0] |
418 since we will use that to read input from. */ | 420 since we will use that to read input from. */ |
422 } | 424 } |
423 | 425 |
424 if (!NILP (fork_error)) | 426 if (!NILP (fork_error)) |
425 signal_error (Qfile_error, fork_error); | 427 signal_error (Qfile_error, fork_error); |
426 | 428 |
427 #ifndef WINDOWSNT | 429 #ifndef WIN32_NATIVE |
428 if (pid < 0) | 430 if (pid < 0) |
429 { | 431 { |
432 int save_errno = errno; | |
430 if (fd[0] >= 0) | 433 if (fd[0] >= 0) |
431 close (fd[0]); | 434 close (fd[0]); |
435 errno = save_errno; | |
432 report_file_error ("Doing fork", Qnil); | 436 report_file_error ("Doing fork", Qnil); |
433 } | 437 } |
434 #endif | 438 #endif |
435 | 439 |
436 if (INTP (buffer)) | 440 if (INTP (buffer)) |
500 /* Now NREAD is the total amount of data in the buffer. */ | 504 /* Now NREAD is the total amount of data in the buffer. */ |
501 if (nread == 0) | 505 if (nread == 0) |
502 break; | 506 break; |
503 | 507 |
504 #if 0 | 508 #if 0 |
505 #ifdef DOS_NT | 509 #ifdef WIN32_NATIVE |
506 /* Until we pull out of MULE things like | 510 /* Until we pull out of MULE things like |
507 make_decoding_input_stream(), we do the following which is | 511 make_decoding_input_stream(), we do the following which is |
508 less elegant. --marcpa */ | 512 less elegant. --marcpa */ |
509 /* We did. -- kkm */ | 513 /* We did. -- kkm */ |
510 { | 514 { |
540 Lstream_close (XLSTREAM (instream)); | 544 Lstream_close (XLSTREAM (instream)); |
541 NUNGCPRO; | 545 NUNGCPRO; |
542 | 546 |
543 QUIT; | 547 QUIT; |
544 /* Wait for it to terminate, unless it already has. */ | 548 /* Wait for it to terminate, unless it already has. */ |
545 #ifdef WINDOWSNT | 549 #ifdef WIN32_NATIVE |
546 wait_for_termination (pHandle); | 550 wait_for_termination (pHandle); |
547 #else | 551 #else |
548 wait_for_termination (pid); | 552 wait_for_termination (pid); |
549 #endif | 553 #endif |
550 | 554 |
600 CURRENT_DIR is an elisp string giving the path of the current | 604 CURRENT_DIR is an elisp string giving the path of the current |
601 directory the subprocess should have. Since we can't really signal | 605 directory the subprocess should have. Since we can't really signal |
602 a decent error from within the child, this should be verified as an | 606 a decent error from within the child, this should be verified as an |
603 executable directory by the parent. */ | 607 executable directory by the parent. */ |
604 | 608 |
605 #ifdef WINDOWSNT | 609 #ifdef WIN32_NATIVE |
606 int | 610 int |
607 #else | 611 #else |
608 void | 612 void |
609 #endif | 613 #endif |
610 child_setup (int in, int out, int err, char **new_argv, | 614 child_setup (int in, int out, int err, char **new_argv, |
611 CONST char *current_dir) | 615 const char *current_dir) |
612 { | 616 { |
613 char **env; | 617 char **env; |
614 char *pwd; | 618 char *pwd; |
615 #ifdef WINDOWSNT | 619 #ifdef WIN32_NATIVE |
616 int cpid; | 620 int cpid; |
617 HANDLE handles[4]; | 621 HANDLE handles[4]; |
618 #endif /* WINDOWSNT */ | 622 #endif /* WIN32_NATIVE */ |
619 | 623 |
620 #ifdef SET_EMACS_PRIORITY | 624 #ifdef SET_EMACS_PRIORITY |
621 if (emacs_priority != 0) | 625 if (emacs_priority != 0) |
622 nice (- emacs_priority); | 626 nice (- emacs_priority); |
623 #endif | 627 #endif |
624 | 628 |
625 #if !defined (NO_SUBPROCESSES) && !defined (WINDOWSNT) | 629 /* Under Windows, we are not in a child process at all, so we should |
630 not close handles inherited from the parent -- we are the parent | |
631 and doing so will screw up all manner of things! Similarly, most | |
632 of the rest of the cleanup done in this function is not done | |
633 under Windows. | |
634 | |
635 #### This entire child_setup() function is an utter and complete | |
636 piece of shit. I would rewrite it, at the very least splitting | |
637 out the Windows and non-Windows stuff into two completely | |
638 different functions; but instead I'm trying to make it go away | |
639 entirely, using the Lisp definition in process.el. What's left | |
640 is to fix up the routines in event-msw.c (and in event-Xt.c and | |
641 event-tty.c) to allow for stream devices to be handled correctly. | |
642 There isn't much to do, in fact, and I'll fix it shortly. That | |
643 way, the Lisp definition can be used non-interactively too. */ | |
644 #if !defined (NO_SUBPROCESSES) && !defined (WIN32_NATIVE) | |
626 /* Close Emacs's descriptors that this process should not have. */ | 645 /* Close Emacs's descriptors that this process should not have. */ |
627 close_process_descs (); | 646 close_process_descs (); |
628 #endif /* not NO_SUBPROCESSES */ | 647 #endif /* not NO_SUBPROCESSES */ |
648 #ifndef WIN32_NATIVE | |
629 close_load_descs (); | 649 close_load_descs (); |
650 #endif | |
630 | 651 |
631 /* Note that use of alloca is always safe here. It's obvious for systems | 652 /* Note that use of alloca is always safe here. It's obvious for systems |
632 that do not have true vfork or that have true (stack) alloca. | 653 that do not have true vfork or that have true (stack) alloca. |
633 If using vfork and C_ALLOCA it is safe because that changes | 654 If using vfork and C_ALLOCA it is safe because that changes |
634 the superior's static variables as if the superior had done alloca | 655 the superior's static variables as if the superior had done alloca |
719 duplicate: ; | 740 duplicate: ; |
720 } | 741 } |
721 *new_env = 0; | 742 *new_env = 0; |
722 } | 743 } |
723 | 744 |
724 #ifdef WINDOWSNT | 745 #ifdef WIN32_NATIVE |
725 prepare_standard_handles (in, out, err, handles); | 746 prepare_standard_handles (in, out, err, handles); |
726 set_process_dir (current_dir); | 747 set_process_dir (current_dir); |
727 #else /* not WINDOWSNT */ | 748 #else /* not WIN32_NATIVE */ |
728 /* Make sure that in, out, and err are not actually already in | 749 /* Make sure that in, out, and err are not actually already in |
729 descriptors zero, one, or two; this could happen if Emacs is | 750 descriptors zero, one, or two; this could happen if Emacs is |
730 started with its standard in, out, or error closed, as might | 751 started with its standard in, out, or error closed, as might |
731 happen under X. */ | 752 happen under X. */ |
732 in = relocate_fd (in, 3); | 753 in = relocate_fd (in, 3); |
753 { | 774 { |
754 int fd; | 775 int fd; |
755 for (fd=3; fd<=64; fd++) | 776 for (fd=3; fd<=64; fd++) |
756 close (fd); | 777 close (fd); |
757 } | 778 } |
758 #endif /* not WINDOWSNT */ | 779 #endif /* not WIN32_NATIVE */ |
759 | 780 |
760 #ifdef vipc | 781 #ifdef vipc |
761 something missing here; | 782 something missing here; |
762 #endif /* vipc */ | 783 #endif /* vipc */ |
763 | 784 |
764 #ifdef WINDOWSNT | 785 #ifdef WIN32_NATIVE |
765 /* Spawn the child. (See ntproc.c:Spawnve). */ | 786 /* Spawn the child. (See ntproc.c:Spawnve). */ |
766 cpid = spawnve (_P_NOWAIT, new_argv[0], (CONST char* CONST*)new_argv, | 787 cpid = spawnve (_P_NOWAIT, new_argv[0], (const char* const*)new_argv, |
767 (CONST char* CONST*)env); | 788 (const char* const*)env); |
768 if (cpid == -1) | 789 if (cpid == -1) |
769 /* An error occurred while trying to spawn the process. */ | 790 /* An error occurred while trying to spawn the process. */ |
770 report_file_error ("Spawning child process", Qnil); | 791 report_file_error ("Spawning child process", Qnil); |
771 reset_standard_handles (in, out, err, handles); | 792 reset_standard_handles (in, out, err, handles); |
772 return cpid; | 793 return cpid; |
773 #else /* not WINDOWSNT */ | 794 #else /* not WIN32_NATIVE */ |
774 /* execvp does not accept an environment arg so the only way | 795 /* execvp does not accept an environment arg so the only way |
775 to pass this environment is to set environ. Our caller | 796 to pass this environment is to set environ. Our caller |
776 is responsible for restoring the ambient value of environ. */ | 797 is responsible for restoring the ambient value of environ. */ |
777 environ = env; | 798 environ = env; |
778 execvp (new_argv[0], new_argv); | 799 execvp (new_argv[0], new_argv); |
779 | 800 |
780 stdout_out ("Can't exec program %s\n", new_argv[0]); | 801 stdout_out ("Can't exec program %s\n", new_argv[0]); |
781 _exit (1); | 802 _exit (1); |
782 #endif /* not WINDOWSNT */ | 803 #endif /* not WIN32_NATIVE */ |
783 } | 804 } |
784 | 805 |
785 static int | 806 static int |
786 getenv_internal (CONST Bufbyte *var, | 807 getenv_internal (const Bufbyte *var, |
787 Bytecount varlen, | 808 Bytecount varlen, |
788 Bufbyte **value, | 809 Bufbyte **value, |
789 Bytecount *valuelen) | 810 Bytecount *valuelen) |
790 { | 811 { |
791 Lisp_Object scan; | 812 Lisp_Object scan; |
795 Lisp_Object entry = XCAR (scan); | 816 Lisp_Object entry = XCAR (scan); |
796 | 817 |
797 if (STRINGP (entry) | 818 if (STRINGP (entry) |
798 && XSTRING_LENGTH (entry) > varlen | 819 && XSTRING_LENGTH (entry) > varlen |
799 && XSTRING_BYTE (entry, varlen) == '=' | 820 && XSTRING_BYTE (entry, varlen) == '=' |
800 #ifdef WINDOWSNT | 821 #ifdef WIN32_NATIVE |
801 /* NT environment variables are case insensitive. */ | 822 /* NT environment variables are case insensitive. */ |
802 && ! memicmp (XSTRING_DATA (entry), var, varlen) | 823 && ! memicmp (XSTRING_DATA (entry), var, varlen) |
803 #else /* not WINDOWSNT */ | 824 #else /* not WIN32_NATIVE */ |
804 && ! memcmp (XSTRING_DATA (entry), var, varlen) | 825 && ! memcmp (XSTRING_DATA (entry), var, varlen) |
805 #endif /* not WINDOWSNT */ | 826 #endif /* not WIN32_NATIVE */ |
806 ) | 827 ) |
807 { | 828 { |
808 *value = XSTRING_DATA (entry) + (varlen + 1); | 829 *value = XSTRING_DATA (entry) + (varlen + 1); |
809 *valuelen = XSTRING_LENGTH (entry) - (varlen + 1); | 830 *valuelen = XSTRING_LENGTH (entry) - (varlen + 1); |
810 return 1; | 831 return 1; |
844 } | 865 } |
845 | 866 |
846 /* A version of getenv that consults process_environment, easily | 867 /* A version of getenv that consults process_environment, easily |
847 callable from C. */ | 868 callable from C. */ |
848 char * | 869 char * |
849 egetenv (CONST char *var) | 870 egetenv (const char *var) |
850 { | 871 { |
872 /* This cannot GC -- 7-28-00 ben */ | |
851 Bufbyte *value; | 873 Bufbyte *value; |
852 Bytecount valuelen; | 874 Bytecount valuelen; |
853 | 875 |
854 if (getenv_internal ((CONST Bufbyte *) var, strlen (var), &value, &valuelen)) | 876 if (getenv_internal ((const Bufbyte *) var, strlen (var), &value, &valuelen)) |
855 return (char *) value; | 877 return (char *) value; |
856 else | 878 else |
857 return 0; | 879 return 0; |
858 } | 880 } |
859 | 881 |
873 Fcons (build_ext_string (*envp, Qfile_name), Vprocess_environment); | 895 Fcons (build_ext_string (*envp, Qfile_name), Vprocess_environment); |
874 } | 896 } |
875 | 897 |
876 { | 898 { |
877 /* Initialize shell-file-name from environment variables or best guess. */ | 899 /* Initialize shell-file-name from environment variables or best guess. */ |
878 #ifdef WINDOWSNT | 900 #ifdef WIN32_NATIVE |
879 CONST char *shell = egetenv ("COMSPEC"); | 901 const char *shell = egetenv ("COMSPEC"); |
880 if (!shell) shell = "\\WINNT\\system32\\cmd.exe"; | 902 if (!shell) shell = "\\WINNT\\system32\\cmd.exe"; |
881 #else /* not WINDOWSNT */ | 903 #else /* not WIN32_NATIVE */ |
882 CONST char *shell = egetenv ("SHELL"); | 904 const char *shell = egetenv ("SHELL"); |
883 if (!shell) shell = "/bin/sh"; | 905 if (!shell) shell = "/bin/sh"; |
884 #endif | 906 #endif |
885 | 907 |
886 Vshell_file_name = build_string (shell); | 908 Vshell_file_name = build_string (shell); |
887 } | 909 } |
904 #endif /* unused */ | 926 #endif /* unused */ |
905 | 927 |
906 void | 928 void |
907 syms_of_callproc (void) | 929 syms_of_callproc (void) |
908 { | 930 { |
909 DEFSUBR (Fcall_process_internal); | 931 DEFSUBR (Fold_call_process_internal); |
910 DEFSUBR (Fgetenv); | 932 DEFSUBR (Fgetenv); |
911 } | 933 } |
912 | 934 |
913 void | 935 void |
914 vars_of_callproc (void) | 936 vars_of_callproc (void) |
915 { | 937 { |
916 /* This function can GC */ | 938 /* This function can GC */ |
917 #ifdef DOS_NT | 939 #ifdef WIN32_NATIVE |
918 DEFVAR_LISP ("binary-process-input", &Vbinary_process_input /* | 940 DEFVAR_LISP ("binary-process-input", &Vbinary_process_input /* |
919 *If non-nil then new subprocesses are assumed to take binary input. | 941 *If non-nil then new subprocesses are assumed to take binary input. |
920 */ ); | 942 */ ); |
921 Vbinary_process_input = Qnil; | 943 Vbinary_process_input = Qnil; |
922 | 944 |
923 DEFVAR_LISP ("binary-process-output", &Vbinary_process_output /* | 945 DEFVAR_LISP ("binary-process-output", &Vbinary_process_output /* |
924 *If non-nil then new subprocesses are assumed to produce binary output. | 946 *If non-nil then new subprocesses are assumed to produce binary output. |
925 */ ); | 947 */ ); |
926 Vbinary_process_output = Qnil; | 948 Vbinary_process_output = Qnil; |
927 #endif /* DOS_NT */ | 949 #endif /* WIN32_NATIVE */ |
928 | 950 |
929 DEFVAR_LISP ("shell-file-name", &Vshell_file_name /* | 951 DEFVAR_LISP ("shell-file-name", &Vshell_file_name /* |
930 *File name to load inferior shells from. | 952 *File name to load inferior shells from. |
931 Initialized from the SHELL environment variable. | 953 Initialized from the SHELL environment variable. |
932 */ ); | 954 */ ); |