comparison src/sysdep.c @ 404:2f8bb876ab1d r21-2-32

Import from CVS: tag r21-2-32
author cvs
date Mon, 13 Aug 2007 11:16:07 +0200
parents a86b2b5e0111
children b8cc9ab3f761
comparison
equal deleted inserted replaced
403:9f011ab08d48 404:2f8bb876ab1d
89 #endif 89 #endif
90 90
91 #ifdef WINDOWSNT 91 #ifdef WINDOWSNT
92 #include <sys/utime.h> 92 #include <sys/utime.h>
93 #include "ntheap.h" 93 #include "ntheap.h"
94 #endif
95
96 #ifdef HAVE_MMAP
97 #include <unistd.h>
98 #include <sys/mman.h>
94 #endif 99 #endif
95 100
96 /* ------------------------------- */ 101 /* ------------------------------- */
97 /* TTY definitions */ 102 /* TTY definitions */
98 /* ------------------------------- */ 103 /* ------------------------------- */
610 saved_handlers++; 615 saved_handlers++;
611 } 616 }
612 } 617 }
613 618
614 #ifdef WINDOWSNT 619 #ifdef WINDOWSNT
620
615 pid_t 621 pid_t
616 sys_getpid (void) 622 sys_getpid (void)
617 { 623 {
618 return abs (getpid ()); 624 return abs (getpid ());
619 } 625 }
626
620 #endif /* WINDOWSNT */ 627 #endif /* WINDOWSNT */
621 628
622 /* Fork a subshell. */ 629 /* Fork a subshell. */
623 static void 630 static void
624 sys_subshell (void) 631 sys_subshell (void)
625 { 632 {
626 #ifdef WINDOWSNT 633 #ifndef WINDOWSNT
627 HANDLE pid;
628 #else
629 int pid; 634 int pid;
630 #endif 635 #endif
631 struct save_signal saved_handlers[5]; 636 struct save_signal saved_handlers[5];
632 Lisp_Object dir; 637 Lisp_Object dir;
633 unsigned char *str = 0; 638 unsigned char *str = 0;
658 dir = expand_and_dir_to_file (dir, Qnil); 663 dir = expand_and_dir_to_file (dir, Qnil);
659 UNGCPRO; 664 UNGCPRO;
660 str = (unsigned char *) alloca (XSTRING_LENGTH (dir) + 2); 665 str = (unsigned char *) alloca (XSTRING_LENGTH (dir) + 2);
661 len = XSTRING_LENGTH (dir); 666 len = XSTRING_LENGTH (dir);
662 memcpy (str, XSTRING_DATA (dir), len); 667 memcpy (str, XSTRING_DATA (dir), len);
663 /* #### Unix specific */ 668 if (!IS_ANY_SEP (str[len - 1]))
664 if (str[len - 1] != '/') str[len++] = '/'; 669 str[len++] = DIRECTORY_SEP;
665 str[len] = 0; 670 str[len] = 0;
666 xyzzy: 671 xyzzy:
667 672
668 #ifdef WINDOWSNT 673 #ifndef WINDOWSNT
669 pid = NULL;
670 #else /* not WINDOWSNT */
671
672 pid = fork (); 674 pid = fork ();
673 675
674 if (pid == -1) 676 if (pid == -1)
675 error ("Can't spawn subshell"); 677 error ("Can't spawn subshell");
676 if (pid == 0) 678 if (pid == 0)
677
678 #endif /* not WINDOWSNT */ 679 #endif /* not WINDOWSNT */
679 { 680 {
680 char *sh = 0; 681 char *sh = 0;
681 682
682 if (sh == 0) 683 if (sh == 0)
686 687
687 /* Use our buffer's default directory for the subshell. */ 688 /* Use our buffer's default directory for the subshell. */
688 if (str) 689 if (str)
689 sys_chdir (str); 690 sys_chdir (str);
690 691
691 #if !defined (NO_SUBPROCESSES) && !defined (WINDOWSNT) 692 #ifdef WINDOWSNT
693
694 /* Waits for process completion */
695 if (_spawnlp (_P_WAIT, sh, sh, NULL) != 0)
696 error ("Can't spawn subshell");
697 else
698 return; /* we're done, no need to wait for termination */
699 }
700
701 #else
702
703 #if !defined (NO_SUBPROCESSES)
692 close_process_descs (); /* Close Emacs's pipes/ptys */ 704 close_process_descs (); /* Close Emacs's pipes/ptys */
693 #endif 705 #endif
694 706
695 #ifdef SET_EMACS_PRIORITY 707 #ifdef SET_EMACS_PRIORITY
696 if (emacs_priority != 0) 708 if (emacs_priority != 0)
697 nice (-emacs_priority); /* Give the new shell the default priority */ 709 nice (-emacs_priority); /* Give the new shell the default priority */
698 #endif 710 #endif
699 711
700 #ifdef WINDOWSNT
701 /* Waits for process completion */
702 pid = (HANDLE) _spawnlp (_P_WAIT, sh, sh, NULL);
703 if (pid == NULL)
704 write (1, "Can't execute subshell", 22);
705
706 #else /* not WINDOWSNT */
707 execlp (sh, sh, 0); 712 execlp (sh, sh, 0);
708 write (1, "Can't execute subshell", 22); 713 write (1, "Can't execute subshell", 22);
709 _exit (1); 714 _exit (1);
710 #endif /* not WINDOWSNT */
711 } 715 }
712 716
713 save_signal_handlers (saved_handlers); 717 save_signal_handlers (saved_handlers);
714 synch_process_alive = 1; 718 synch_process_alive = 1;
715 wait_for_termination (pid); 719 wait_for_termination (pid);
716 restore_signal_handlers (saved_handlers); 720 restore_signal_handlers (saved_handlers);
721
722 #endif /* not WINDOWSNT */
723
717 } 724 }
718 725
719 #endif /* !defined (SIGTSTP) && !defined (USG_JOBCTRL) */ 726 #endif /* !defined (SIGTSTP) && !defined (USG_JOBCTRL) */
720 727
721 728
2189 * at the normal shared text boundary and the startofdata variable 2196 * at the normal shared text boundary and the startofdata variable
2190 * will be patched by unexec to the correct value. 2197 * will be patched by unexec to the correct value.
2191 * 2198 *
2192 */ 2199 */
2193 2200
2194 #ifdef ORDINARY_LINK 2201 #if defined(ORDINARY_LINK) && !defined(__MINGW32__)
2195 extern char **environ; 2202 extern char **environ;
2196 #endif 2203 #endif
2197 2204
2198 void * 2205 void *
2199 start_of_data (void) 2206 start_of_data (void)
2206 * This is a hack. Since we're not linking crt0.c or pre_crt0.c, 2213 * This is a hack. Since we're not linking crt0.c or pre_crt0.c,
2207 * data_start isn't defined. We take the address of environ, which 2214 * data_start isn't defined. We take the address of environ, which
2208 * is known to live at or near the start of the system crt0.c, and 2215 * is known to live at or near the start of the system crt0.c, and
2209 * we don't sweat the handful of bytes that might lose. 2216 * we don't sweat the handful of bytes that might lose.
2210 */ 2217 */
2211 #ifdef HEAP_IN_DATA 2218 #if defined (HEAP_IN_DATA) && !defined(PDUMP)
2212 extern char* static_heap_base; 2219 extern char* static_heap_base;
2213 if (!initialized) 2220 if (!initialized)
2214 return static_heap_base; 2221 return static_heap_base;
2215 #endif 2222 #endif
2216 return((char *) &environ); 2223 return((char *) &environ);