diff src/sysdep.c @ 371:cc15677e0335 r21-2b1

Import from CVS: tag r21-2b1
author cvs
date Mon, 13 Aug 2007 11:03:08 +0200
parents a4f53d9b3154
children 8626e4521993
line wrap: on
line diff
--- a/src/sysdep.c	Mon Aug 13 11:01:58 2007 +0200
+++ b/src/sysdep.c	Mon Aug 13 11:03:08 2007 +0200
@@ -233,11 +233,8 @@
 #endif /* NO_SUBPROCESSES */
 
 
-#ifdef WINDOWSNT
-void wait_for_termination (HANDLE pHandle)
-#else
-void wait_for_termination (int pid)
-#endif
+void
+wait_for_termination (int pid)
 {
   /* #### With the new improved SIGCHLD handling stuff, there is much
      less danger of race conditions and some of the comments below
@@ -347,53 +344,6 @@
 
      Since implementations may add their own error indicators on top,
      we ignore it by default.  */
-#elif defined (WINDOWSNT)
-  int ret = 0, status = 0;
-  if (pHandle == NULL)
-    {
-      warn_when_safe (Qprocess, Qerror, "Cannot wait for NULL process handle.");
-      return;
-    }
-  do
-    {
-      QUIT;
-      ret = WaitForSingleObject(pHandle, 100);
-    }
-  while (ret == WAIT_TIMEOUT);
-  if (ret == WAIT_FAILED)
-    {
-      warn_when_safe (Qprocess, Qerror,
-		      "WaitForSingleObject returns WAIT_FAILED for process handle %p.",
-		      pHandle);
-    }
-  if (ret == WAIT_ABANDONED)
-    {
-      warn_when_safe (Qprocess, Qerror,
-		      "WaitForSingleObject returns WAIT_ABANDONED for process handle %p.",
-		      pHandle);
-    }
-  if (ret == WAIT_OBJECT_0)
-    {
-      ret = GetExitCodeProcess(pHandle, &status);
-      if (ret)
-	{
-	  synch_process_alive = 0;
-	  synch_process_retcode = status;
-	}
-      else
-	{
-	  /* GetExitCodeProcess() didn't return a valid exit status,
-	     nothing to do.  APA */
-	  warn_when_safe (Qprocess, Qerror,
-			  "GetExitCodeProcess fails for process handle %p.",
-			  pHandle);
-	}
-    }
-  if (pHandle != NULL && !CloseHandle(pHandle))
-    {
-      warn_when_safe (Qprocess, Qerror,
-		      "CloseHandle fails for process handle %p.", pHandle);
-    }
 #elif defined (EMACS_BLOCK_SIGNAL) && !defined (BROKEN_WAIT_FOR_SIGNAL) && defined (SIGCHLD)
   while (1)
     {
@@ -425,7 +375,7 @@
 	   Try defining BROKEN_WAIT_FOR_SIGNAL. */
 	EMACS_WAIT_FOR_SIGNAL (SIGCHLD);
     }
-#else /* not HAVE_WAITPID and not WINDOWSNT and (not EMACS_BLOCK_SIGNAL or BROKEN_WAIT_FOR_SIGNAL) */
+#else /* not HAVE_WAITPID and (not EMACS_BLOCK_SIGNAL or BROKEN_WAIT_FOR_SIGNAL) */
   /* This approach is kind of cheesy but is guaranteed(?!) to work
      for all systems. */
   while (1)
@@ -627,11 +577,7 @@
 static void
 sys_subshell (void)
 {
-#ifdef WINDOWSNT
-  HANDLE pid;
-#else
   int pid;
-#endif
   struct save_signal saved_handlers[5];
   Lisp_Object dir;
   unsigned char *str = 0;
@@ -670,7 +616,7 @@
  xyzzy:
 
 #ifdef WINDOWSNT
-  pid = NULL;
+  pid = -1;
 #else /* not WINDOWSNT */
 
   pid = fork ();
@@ -704,7 +650,7 @@
 #ifdef WINDOWSNT
       /* Waits for process completion */
       pid = _spawnlp (_P_WAIT, sh, sh, NULL);
-      if (pid == NULL)
+      if (pid == -1)
         write (1, "Can't execute subshell", 22);
 
 #else   /* not WINDOWSNT */
@@ -769,31 +715,18 @@
 int
 get_pty_max_bytes (int fd)
 {
-  /* DEC OSF 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 120
+  int pty_max_bytes;
+
 #if defined (HAVE_FPATHCONF) && defined (_PC_MAX_CANON)
-  {
-    int max_canon = fpathconf (fd, _PC_MAX_CANON);
-#ifdef __hpux__
-    /* HP-UX 10.20 fpathconf returns 768, but this results in
-       truncated input lines, while 255 works. */
-    if (max_canon > 255) max_canon = 255;
+  pty_max_bytes = fpathconf (fd, _PC_MAX_CANON);
+  if (pty_max_bytes < 0)
 #endif
-    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. */
@@ -1084,7 +1017,7 @@
 {
   int filedesc = DEVICE_INFD (d);
 
-#if defined (I_SETSIG) && !defined(HPUX10) && !defined(LINUX)
+#if defined (I_SETSIG) && !defined(HPUX10)
   {
     int events=0;
     ioctl (filedesc, I_GETSIG, &events);
@@ -1129,7 +1062,7 @@
 {
   int filedesc = DEVICE_INFD (d);
 
-#if defined (I_SETSIG) && !defined(HPUX10) && !defined(LINUX)
+#if defined (I_SETSIG) && !defined(HPUX10)
   {
     int events=0;
     ioctl (filedesc, I_GETSIG, &events);
@@ -3102,15 +3035,6 @@
 #endif /* ENCAPSULATE_READLINK */
 
 
-#ifdef ENCAPSULATE_FSTAT
-int
-sys_fstat (int fd, struct stat *buf)
-{
-  return fstat (fd, buf);
-}
-#endif /* ENCAPSULATE_FSTAT */
-
-
 #ifdef ENCAPSULATE_STAT
 int
 sys_stat (CONST char *path, struct stat *buf)