comparison src/callproc.c @ 440:8de8e3f6228a r21-2-28

Import from CVS: tag r21-2-28
author cvs
date Mon, 13 Aug 2007 11:33:38 +0200
parents 3a7e78e1142d
children abe6d1db359e
comparison
equal deleted inserted replaced
439:357dd071b03c 440:8de8e3f6228a
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 WINDOWSNT
45 #define _P_NOWAIT 1 /* from process.h */ 45 #define _P_NOWAIT 1 /* from process.h */
46 #include <windows.h>
47 #include "nt.h" 46 #include "nt.h"
48 #endif 47 #endif
49 48
50 #ifdef DOS_NT 49 #ifdef DOS_NT
51 /* 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
100 } 99 }
101 100
102 static Lisp_Object 101 static Lisp_Object
103 call_process_cleanup (Lisp_Object fdpid) 102 call_process_cleanup (Lisp_Object fdpid)
104 { 103 {
105 int fd = XINT (Fcar (fdpid)); 104 int fd = XINT (Fcar (fdpid));
106 int pid = XINT (Fcdr (fdpid)); 105 int pid = XINT (Fcdr (fdpid));
107 #ifdef WINDOWSNT
108 HANDLE pHandle;
109 #endif
110 106
111 if (!call_process_exited && 107 if (!call_process_exited &&
112 EMACS_KILLPG (pid, SIGINT) == 0) 108 EMACS_KILLPG (pid, SIGINT) == 0)
113 { 109 {
114 int speccount = specpdl_depth (); 110 int speccount = specpdl_depth ();
116 record_unwind_protect (call_process_kill, fdpid); 112 record_unwind_protect (call_process_kill, fdpid);
117 /* #### "c-G" -- need non-consing Single-key-description */ 113 /* #### "c-G" -- need non-consing Single-key-description */
118 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)");
119 115
120 #ifdef WINDOWSNT 116 #ifdef WINDOWSNT
121 pHandle = OpenProcess(PROCESS_ALL_ACCESS, 0, pid); 117 {
122 if (pHandle == NULL) 118 HANDLE pHandle = OpenProcess (PROCESS_ALL_ACCESS, 0, pid);
123 { 119 if (pHandle == NULL)
124 warn_when_safe (Qprocess, Qwarning, 120 warn_when_safe (Qprocess, Qwarning,
125 "cannot open process (PID %d) for cleanup", pid); 121 "cannot open process (PID %d) for cleanup", pid);
126 } 122 else
127 wait_for_termination (pHandle); 123 wait_for_termination (pHandle);
124 }
128 #else 125 #else
129 wait_for_termination (pid); 126 wait_for_termination (pid);
130 #endif 127 #endif
131 128
132 /* "Discard" the unwind protect. */ 129 /* "Discard" the unwind protect. */
502 499
503 /* Now NREAD is the total amount of data in the buffer. */ 500 /* Now NREAD is the total amount of data in the buffer. */
504 if (nread == 0) 501 if (nread == 0)
505 break; 502 break;
506 503
504 #if 0
507 #ifdef DOS_NT 505 #ifdef DOS_NT
508 /* Until we pull out of MULE things like 506 /* Until we pull out of MULE things like
509 make_decoding_input_stream(), we do the following which is 507 make_decoding_input_stream(), we do the following which is
510 less elegant. --marcpa */ 508 less elegant. --marcpa */
509 /* We did. -- kkm */
511 { 510 {
512 int lf_count = 0; 511 int lf_count = 0;
513 if (NILP (Vbinary_process_output)) { 512 if (NILP (Vbinary_process_output)) {
514 nread = crlf_to_lf(nread, bufptr, &lf_count); 513 nread = crlf_to_lf(nread, bufptr, &lf_count);
515 } 514 }
516 } 515 }
516 #endif
517 #endif 517 #endif
518 518
519 total_read += nread; 519 total_read += nread;
520 520
521 if (!NILP (buffer)) 521 if (!NILP (buffer))
682 CONSP (tail) && STRINGP (XCAR (tail)); 682 CONSP (tail) && STRINGP (XCAR (tail));
683 tail = XCDR (tail)) 683 tail = XCDR (tail))
684 { 684 {
685 char **ep = env; 685 char **ep = env;
686 char *envvar_external; 686 char *envvar_external;
687 Bufbyte *envvar_internal = XSTRING_DATA (XCAR (tail)); 687
688 688 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (tail),
689 GET_C_CHARPTR_EXT_FILENAME_DATA_ALLOCA (envvar_internal, envvar_external); 689 C_STRING_ALLOCA, envvar_external,
690 Qfile_name);
690 691
691 /* See if envvar_external duplicates any string already in the env. 692 /* See if envvar_external duplicates any string already in the env.
692 If so, don't put it in. 693 If so, don't put it in.
693 When an env var has multiple definitions, 694 When an env var has multiple definitions,
694 we keep the definition that comes first in process-environment. */ 695 we keep the definition that comes first in process-environment. */
866 /* jwz: always initialize Vprocess_environment, so that egetenv() 867 /* jwz: always initialize Vprocess_environment, so that egetenv()
867 works in temacs. */ 868 works in temacs. */
868 char **envp; 869 char **envp;
869 Vprocess_environment = Qnil; 870 Vprocess_environment = Qnil;
870 for (envp = environ; envp && *envp; envp++) 871 for (envp = environ; envp && *envp; envp++)
871 { 872 Vprocess_environment =
872 Vprocess_environment = Fcons (build_ext_string (*envp, FORMAT_OS), 873 Fcons (build_ext_string (*envp, Qfile_name), Vprocess_environment);
873 Vprocess_environment);
874 }
875 } 874 }
876 875
877 { 876 {
878 /* Initialize shell-file-name from environment variables or best guess. */ 877 /* Initialize shell-file-name from environment variables or best guess. */
879 #ifdef WINDOWSNT 878 #ifdef WINDOWSNT