Mercurial > hg > xemacs-beta
comparison src/callproc.c @ 357:4711e16a8e49 r21-1-8
Import from CVS: tag r21-1-8
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:57:04 +0200 |
parents | 19dcec799385 |
children | 8e84bee8ddd0 |
comparison
equal
deleted
inserted
replaced
356:e85f639a32f3 | 357:4711e16a8e49 |
---|---|
102 static Lisp_Object | 102 static Lisp_Object |
103 call_process_cleanup (Lisp_Object fdpid) | 103 call_process_cleanup (Lisp_Object fdpid) |
104 { | 104 { |
105 int fd = XINT (Fcar (fdpid)); | 105 int fd = XINT (Fcar (fdpid)); |
106 int pid = XINT (Fcdr (fdpid)); | 106 int pid = XINT (Fcdr (fdpid)); |
107 #ifdef WINDOWSNT | |
108 HANDLE pHandle; | |
109 #endif | |
107 | 110 |
108 if (!call_process_exited && | 111 if (!call_process_exited && |
109 EMACS_KILLPG (pid, SIGINT) == 0) | 112 EMACS_KILLPG (pid, SIGINT) == 0) |
110 { | 113 { |
111 int speccount = specpdl_depth (); | 114 int speccount = specpdl_depth (); |
112 | 115 |
113 record_unwind_protect (call_process_kill, fdpid); | 116 record_unwind_protect (call_process_kill, fdpid); |
114 /* #### "c-G" -- need non-consing Single-key-description */ | 117 /* #### "c-G" -- need non-consing Single-key-description */ |
115 message ("Waiting for process to die...(type C-g again to kill it instantly)"); | 118 message ("Waiting for process to die...(type C-g again to kill it instantly)"); |
116 | 119 |
120 #ifdef WINDOWSNT | |
121 pHandle = OpenProcess(PROCESS_ALL_ACCESS, 0, pid); | |
122 if (pHandle == NULL) | |
123 { | |
124 stderr_out ("call_process_cleanup.OpenProcess: pHandle == NULL, GetLastError () = %d, (int)pHandle = %d\n", GetLastError (), (int)pHandle); | |
125 } | |
126 wait_for_termination (pHandle); | |
127 #else | |
117 wait_for_termination (pid); | 128 wait_for_termination (pid); |
129 #endif | |
118 | 130 |
119 /* "Discard" the unwind protect. */ | 131 /* "Discard" the unwind protect. */ |
120 XCAR (fdpid) = Qnil; | 132 XCAR (fdpid) = Qnil; |
121 XCDR (fdpid) = Qnil; | 133 XCDR (fdpid) = Qnil; |
122 unbind_to (speccount, Qnil); | 134 unbind_to (speccount, Qnil); |
168 { | 180 { |
169 /* This function can GC */ | 181 /* This function can GC */ |
170 Lisp_Object infile, buffer, current_dir, display, path; | 182 Lisp_Object infile, buffer, current_dir, display, path; |
171 int fd[2]; | 183 int fd[2]; |
172 int filefd; | 184 int filefd; |
185 #ifdef WINDOWSNT | |
186 HANDLE pHandle; | |
187 #endif | |
173 int pid; | 188 int pid; |
174 char buf[16384]; | 189 char buf[16384]; |
175 char *bufptr = buf; | 190 char *bufptr = buf; |
176 int bufsize = 16384; | 191 int bufsize = 16384; |
177 int speccount = specpdl_depth (); | 192 int speccount = specpdl_depth (); |
365 | 380 |
366 fork_error = Qnil; | 381 fork_error = Qnil; |
367 #ifdef WINDOWSNT | 382 #ifdef WINDOWSNT |
368 pid = child_setup (filefd, fd1, fd_error, new_argv, | 383 pid = child_setup (filefd, fd1, fd_error, new_argv, |
369 (char *) XSTRING_DATA (current_dir)); | 384 (char *) XSTRING_DATA (current_dir)); |
385 if (!INTP (buffer)) | |
386 { | |
387 /* OpenProcess() as soon after child_setup as possible. It's too | |
388 late once the process terminated. */ | |
389 pHandle = OpenProcess(PROCESS_ALL_ACCESS, 0, pid); | |
390 if (pHandle == NULL) | |
391 { | |
392 stderr_out ("Fcall_process_internal: pHandle == NULL, GetLastError () = %d, (int)pHandle = %d\n", GetLastError (), (int)pHandle); | |
393 } | |
394 } | |
395 /* Close STDERR into the parent process. We no longer need it. */ | |
396 if (fd_error >= 0) | |
397 close (fd_error); | |
370 #else /* not WINDOWSNT */ | 398 #else /* not WINDOWSNT */ |
371 pid = fork (); | 399 pid = fork (); |
372 | 400 |
373 if (pid == 0) | 401 if (pid == 0) |
374 { | 402 { |
404 } | 432 } |
405 | 433 |
406 if (!NILP (fork_error)) | 434 if (!NILP (fork_error)) |
407 signal_error (Qfile_error, fork_error); | 435 signal_error (Qfile_error, fork_error); |
408 | 436 |
437 #ifndef WINDOWSNT | |
409 if (pid < 0) | 438 if (pid < 0) |
410 { | 439 { |
411 if (fd[0] >= 0) | 440 if (fd[0] >= 0) |
412 close (fd[0]); | 441 close (fd[0]); |
413 report_file_error ("Doing fork", Qnil); | 442 report_file_error ("Doing fork", Qnil); |
414 } | 443 } |
444 #endif | |
415 | 445 |
416 if (INTP (buffer)) | 446 if (INTP (buffer)) |
417 { | 447 { |
418 if (fd[0] >= 0) | 448 if (fd[0] >= 0) |
419 close (fd[0]); | 449 close (fd[0]); |
517 Lstream_close (XLSTREAM (instream)); | 547 Lstream_close (XLSTREAM (instream)); |
518 NUNGCPRO; | 548 NUNGCPRO; |
519 | 549 |
520 QUIT; | 550 QUIT; |
521 /* Wait for it to terminate, unless it already has. */ | 551 /* Wait for it to terminate, unless it already has. */ |
552 #ifdef WINDOWSNT | |
553 wait_for_termination (pHandle); | |
554 #else | |
522 wait_for_termination (pid); | 555 wait_for_termination (pid); |
556 #endif | |
523 | 557 |
524 /* Don't kill any children that the subprocess may have left behind | 558 /* Don't kill any children that the subprocess may have left behind |
525 when exiting. */ | 559 when exiting. */ |
526 call_process_exited = 1; | 560 call_process_exited = 1; |
527 unbind_to (speccount, Qnil); | 561 unbind_to (speccount, Qnil); |