comparison src/w32proc.c @ 13425:b6eacb7da9f6

[HAVE_NTGUI] (create_child): Pass handles to children. [HAVE_NTGUI1] (sys_select): Support alternate keyboard handling.
author Geoff Voelker <voelker@cs.washington.edu>
date Tue, 07 Nov 1995 07:35:38 +0000
parents aa6fc4e97a28
children c80fb27c183b
comparison
equal deleted inserted replaced
13424:efbbbfd268dd 13425:b6eacb7da9f6
224 goto EH_char_consumed; 224 goto EH_char_consumed;
225 225
226 memset (&start, 0, sizeof (start)); 226 memset (&start, 0, sizeof (start));
227 start.cb = sizeof (start); 227 start.cb = sizeof (start);
228 228
229 #ifdef HAVE_NTGUI
230 start.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
231 start.wShowWindow = SW_HIDE;
232
233 start.hStdInput = GetStdHandle (STD_INPUT_HANDLE);
234 start.hStdOutput = GetStdHandle (STD_OUTPUT_HANDLE);
235 start.hStdError = GetStdHandle (STD_ERROR_HANDLE);
236 #endif /* HAVE_NTGUI */
237
229 /* Explicitly specify no security */ 238 /* Explicitly specify no security */
230 if (!InitializeSecurityDescriptor (&sec_desc, SECURITY_DESCRIPTOR_REVISION)) 239 if (!InitializeSecurityDescriptor (&sec_desc, SECURITY_DESCRIPTOR_REVISION))
231 goto EH_thrd; 240 goto EH_thrd;
232 if (!SetSecurityDescriptorDacl (&sec_desc, TRUE, NULL, FALSE)) 241 if (!SetSecurityDescriptorDacl (&sec_desc, TRUE, NULL, FALSE))
233 goto EH_thrd; 242 goto EH_thrd;
567 { 576 {
568 SELECT_TYPE orfds; 577 SELECT_TYPE orfds;
569 DWORD timeout_ms; 578 DWORD timeout_ms;
570 int i, nh, nr; 579 int i, nh, nr;
571 DWORD active; 580 DWORD active;
572 child_process *cp, *cps[MAX_CHILDREN]; 581 child_process *cp, *cps[MAX_CHILDREN + 1];
573 HANDLE wait_hnd[MAX_CHILDREN]; 582 HANDLE wait_hnd[MAX_CHILDREN + 1];
583 #ifdef HAVE_NTGUI1
584 BOOL keyboardwait = FALSE ;
585 #endif /* HAVE_NTGUI */
574 586
575 /* If the descriptor sets are NULL but timeout isn't, then just Sleep. */ 587 /* If the descriptor sets are NULL but timeout isn't, then just Sleep. */
576 if (rfds == NULL && wfds == NULL && efds == NULL && timeout != NULL) 588 if (rfds == NULL && wfds == NULL && efds == NULL && timeout != NULL)
577 { 589 {
578 #ifdef HAVE_TIMEVAL 590 #ifdef HAVE_TIMEVAL
599 for (i = 0; i < nfds; i++) 611 for (i = 0; i < nfds; i++)
600 if (FD_ISSET (i, &orfds)) 612 if (FD_ISSET (i, &orfds))
601 { 613 {
602 if (i == 0) 614 if (i == 0)
603 { 615 {
616 #ifdef HAVE_NTGUI1
617 keyboardwait = TRUE ;
618 #else
604 /* Handle stdin specially */ 619 /* Handle stdin specially */
605 wait_hnd[nh] = keyboard_handle; 620 wait_hnd[nh] = keyboard_handle;
606 cps[nh] = NULL; 621 cps[nh] = NULL;
607 nh++; 622 nh++;
623 #endif /* HAVE_NTGUI */
608 624
609 /* Check for any emacs-generated input in the queue since 625 /* Check for any emacs-generated input in the queue since
610 it won't be detected in the wait */ 626 it won't be detected in the wait */
611 if (detect_input_pending ()) 627 if (detect_input_pending ())
612 { 628 {
637 break; 653 break;
638 } 654 }
639 } 655 }
640 } 656 }
641 657
658 /* Never do this in win32 since we will not get paint messages */
659
660 #ifndef HAVE_NTGUI1
642 /* Nothing to look for, so we didn't find anything */ 661 /* Nothing to look for, so we didn't find anything */
643 if (nh == 0) 662 if (nh == 0)
644 { 663 {
645 if (timeout) 664 if (timeout)
646 #ifdef HAVE_TIMEVAL 665 #ifdef HAVE_TIMEVAL
648 #else 667 #else
649 Sleep ((*timeout) * 1000); 668 Sleep ((*timeout) * 1000);
650 #endif 669 #endif
651 return 0; 670 return 0;
652 } 671 }
672 #endif /* !HAVE_NTGUI */
653 673
654 /* Check for immediate return without waiting */ 674 /* Check for immediate return without waiting */
655 if (nr > 0) 675 if (nr > 0)
656 return nr; 676 return nr;
657 677
664 #ifdef HAVE_TIMEVAL 684 #ifdef HAVE_TIMEVAL
665 timeout_ms = timeout ? (timeout->tv_sec * 1000 + timeout->tv_usec / 1000) : INFINITE; 685 timeout_ms = timeout ? (timeout->tv_sec * 1000 + timeout->tv_usec / 1000) : INFINITE;
666 #else 686 #else
667 timeout_ms = timeout ? *timeout*1000 : INFINITE; 687 timeout_ms = timeout ? *timeout*1000 : INFINITE;
668 #endif 688 #endif
689 #ifdef HAVE_NTGUI1
690 active = MsgWaitForMultipleObjects (nh, wait_hnd, FALSE, timeout_ms,QS_ALLINPUT);
691 #else
669 active = WaitForMultipleObjects (nh, wait_hnd, FALSE, timeout_ms); 692 active = WaitForMultipleObjects (nh, wait_hnd, FALSE, timeout_ms);
693 #endif /* HAVE_NTGUI */
670 if (active == WAIT_FAILED) 694 if (active == WAIT_FAILED)
671 { 695 {
672 DebPrint (("select.WaitForMultipleObjects (%d, %lu) failed with %lu\n", 696 DebPrint (("select.WaitForMultipleObjects (%d, %lu) failed with %lu\n",
673 nh, timeout_ms, GetLastError ())); 697 nh, timeout_ms, GetLastError ()));
674 /* Is there a better error? */ 698 /* Is there a better error? */
677 } 701 }
678 else if (active == WAIT_TIMEOUT) 702 else if (active == WAIT_TIMEOUT)
679 { 703 {
680 return 0; 704 return 0;
681 } 705 }
706 #ifdef HAVE_NTGUI1
707 else if (active == WAIT_OBJECT_0 + nh)
708 {
709 /* Keyboard input available */
710 FD_SET (0, rfds);
711
712 /* This shouldn't be necessary, but apparently just setting the input
713 fd is not good enough for emacs */
714 // read_input_waiting ();
715
716 return (1) ;
717 }
718 #endif /* HAVE_NTGUI */
682 else if (active >= WAIT_OBJECT_0 && 719 else if (active >= WAIT_OBJECT_0 &&
683 active < WAIT_OBJECT_0+MAXIMUM_WAIT_OBJECTS) 720 active < WAIT_OBJECT_0+MAXIMUM_WAIT_OBJECTS)
684 { 721 {
685 active -= WAIT_OBJECT_0; 722 active -= WAIT_OBJECT_0;
686 } 723 }