X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fsysdep.c;h=912b3d1fc3ad1baee020f3323307dd36003b94ce;hb=9816585ded614fa87be5a2ecfda6dc16c60beb2c;hp=b875b48cfb6546c18251a5efa9150023f5aeaf4e;hpb=3e447015251ce6dcde843cbed10d9033d5538622;p=chise%2Fxemacs-chise.git- diff --git a/src/sysdep.c b/src/sysdep.c index b875b48..912b3d1 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -612,20 +612,20 @@ restore_signal_handlers (struct save_signal *saved_handlers) } #ifdef WINDOWSNT + pid_t sys_getpid (void) { return abs (getpid ()); } + #endif /* WINDOWSNT */ /* Fork a subshell. */ static void sys_subshell (void) { -#ifdef WINDOWSNT - HANDLE pid; -#else +#ifndef WINDOWSNT int pid; #endif struct save_signal saved_handlers[5]; @@ -660,21 +660,17 @@ sys_subshell (void) str = (unsigned char *) alloca (XSTRING_LENGTH (dir) + 2); len = XSTRING_LENGTH (dir); memcpy (str, XSTRING_DATA (dir), len); - /* #### Unix specific */ - if (str[len - 1] != '/') str[len++] = '/'; + if (!IS_ANY_SEP (str[len - 1])) + str[len++] = DIRECTORY_SEP; str[len] = 0; xyzzy: -#ifdef WINDOWSNT - pid = NULL; -#else /* not WINDOWSNT */ - +#ifndef WINDOWSNT pid = fork (); if (pid == -1) error ("Can't spawn subshell"); if (pid == 0) - #endif /* not WINDOWSNT */ { char *sh = 0; @@ -688,7 +684,18 @@ sys_subshell (void) if (str) sys_chdir (str); -#if !defined (NO_SUBPROCESSES) && !defined (WINDOWSNT) +#ifdef WINDOWSNT + + /* Waits for process completion */ + if (_spawnlp (_P_WAIT, sh, sh, NULL) != 0) + error ("Can't spawn subshell"); + else + return; /* we're done, no need to wait for termination */ + } + +#else + +#if !defined (NO_SUBPROCESSES) close_process_descs (); /* Close Emacs's pipes/ptys */ #endif @@ -697,23 +704,18 @@ sys_subshell (void) nice (-emacs_priority); /* Give the new shell the default priority */ #endif -#ifdef WINDOWSNT - /* Waits for process completion */ - pid = _spawnlp (_P_WAIT, sh, sh, NULL); - if (pid == NULL) - write (1, "Can't execute subshell", 22); - -#else /* not WINDOWSNT */ execlp (sh, sh, 0); write (1, "Can't execute subshell", 22); _exit (1); -#endif /* not WINDOWSNT */ } save_signal_handlers (saved_handlers); synch_process_alive = 1; wait_for_termination (pid); restore_signal_handlers (saved_handlers); + +#endif /* not WINDOWSNT */ + } #endif /* !defined (SIGTSTP) && !defined (USG_JOBCTRL) */ @@ -760,23 +762,31 @@ sys_suspend_process (int process) /* Given FD, obtain pty buffer size. When no luck, a good guess is made, - so that the function works even fd is not a pty. */ + so that the function works even when fd is not a pty. */ int get_pty_max_bytes (int fd) { - int pty_max_bytes; - + /* DEC OSF 4.0 fpathconf returns 255, but xemacs hangs on long shell + input lines if we return 253. 252 is OK!. So let's leave a bit + of slack for the newline that xemacs will insert, and for those + inevitable vendor off-by-one-or-two-or-three bugs. */ +#define MAX_CANON_SLACK 10 +#define SAFE_MAX_CANON (127 - MAX_CANON_SLACK) #if defined (HAVE_FPATHCONF) && defined (_PC_MAX_CANON) - pty_max_bytes = fpathconf (fd, _PC_MAX_CANON); - if (pty_max_bytes < 0) + { + int max_canon = fpathconf (fd, _PC_MAX_CANON); + return (max_canon < 0 ? SAFE_MAX_CANON : + max_canon > SAFE_MAX_CANON ? max_canon - MAX_CANON_SLACK : + max_canon); + } +#elif defined (_POSIX_MAX_CANON) + return (_POSIX_MAX_CANON > SAFE_MAX_CANON ? + _POSIX_MAX_CANON - MAX_CANON_SLACK : + _POSIX_MAX_CANON); +#else + return SAFE_MAX_CANON; #endif - pty_max_bytes = 250; - - /* Deduct one, to leave space for the eof. */ - pty_max_bytes--; - - return pty_max_bytes; } /* Figure out the eof character for the FD. */ @@ -2191,7 +2201,7 @@ start_of_text (void) * */ -#ifdef ORDINARY_LINK +#if defined(ORDINARY_LINK) && !defined(__MINGW32__) extern char **environ; #endif @@ -2208,7 +2218,7 @@ start_of_data (void) * is known to live at or near the start of the system crt0.c, and * we don't sweat the handful of bytes that might lose. */ -#ifdef HEAP_IN_DATA +#if defined (HEAP_IN_DATA) && !defined(PDUMP) extern char* static_heap_base; if (!initialized) return static_heap_base; @@ -2653,6 +2663,8 @@ sys_open (const char *path, int oflag, ...) mode = va_arg (ap, int); va_end (ap); + PATHNAME_CONVERT_OUT (path); + #ifdef WINDOWSNT /* Make all handles non-inheritable */ oflag |= _O_NOINHERIT;