}
#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];
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;
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
nice (-emacs_priority); /* Give the new shell the default priority */
#endif
-#ifdef WINDOWSNT
- /* Waits for process completion */
- pid = (HANDLE) _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) */
\f
/* 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. */
*
*/
-#ifdef ORDINARY_LINK
+#if defined(ORDINARY_LINK) && !defined(__MINGW32__)
extern char **environ;
#endif
* 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;