declare smobs in alloc.c
[bpt/emacs.git] / lib-src / emacsclient.c
index 6593b91..ddc1b6d 100644 (file)
@@ -65,10 +65,6 @@ char *w32_getenv (char *);
 # define CLOSE_SOCKET close
 # define INITIALIZE()
 
-# ifndef WCONTINUED
-#  define WCONTINUED 8
-# endif
-
 #define egetenv(VAR) getenv(VAR)
 
 #endif /* !WINDOWSNT */
@@ -86,10 +82,6 @@ char *w32_getenv (char *);
 #include <signal.h>
 #include <errno.h>
 
-
-\f
-char *getenv (const char *);
-
 #ifndef VERSION
 #define VERSION "unspecified"
 #endif
@@ -1105,16 +1097,18 @@ static void
 handle_sigcont (int signalnum)
 {
   int old_errno = errno;
+  pid_t pgrp = getpgrp ();
+  pid_t tcpgrp = tcgetpgrp (1);
 
-  if (tcgetpgrp (1) == getpgrp ())
+  if (tcpgrp == pgrp)
     {
-      /* We are in the foreground. */
+      /* We are in the foreground.  */
       send_to_emacs (emacs_socket, "-resume \n");
     }
-  else
+  else if (0 <= tcpgrp && tty)
     {
-      /* We are in the background; cancel the continue. */
-      raise (SIGSTOP);
+      /* We are in the background; cancel the continue.  */
+      kill (-pgrp, SIGTTIN);
     }
 
   signal (signalnum, handle_sigcont);
@@ -1554,6 +1548,16 @@ main (int argc, char **argv)
       exit (EXIT_FAILURE);
     }
 
+#ifndef WINDOWSNT
+  if (tty)
+    {
+      pid_t pgrp = getpgrp ();
+      pid_t tcpgrp = tcgetpgrp (1);
+      if (0 <= tcpgrp && tcpgrp != pgrp)
+       kill (-pgrp, SIGTTIN);
+    }
+#endif /* !WINDOWSNT */
+
   /* If alternate_editor is the empty string, start the emacs daemon
      in case of failure to connect.  */
   start_daemon_if_needed = (alternate_editor