]> sourceware.org Git - newlib-cygwin.git/commitdiff
* syscalls.cc (check_tty_fds): New function. Check whether there is a fd
authorChristopher Faylor <me@cgf.cx>
Sat, 25 Aug 2001 17:27:31 +0000 (17:27 +0000)
committerChristopher Faylor <me@cgf.cx>
Sat, 25 Aug 2001 17:27:31 +0000 (17:27 +0000)
referring to pty slave.
(setsid): Don't detach console if the process has a pty slave.

winsup/cygwin/ChangeLog
winsup/cygwin/syscalls.cc

index 87c7c075418f44c084e6aa1c125a2088e74d93f1..c7c4c1eb7681c20ffebdf9d31def3a7771d6c403 100644 (file)
@@ -1,3 +1,9 @@
+2001-08-24  Kazuhiro Fujieda  <fujieda@jaist.ac.jp>
+   
+       * syscalls.cc (check_tty_fds): New function.  Check whether there is a
+       fd referring to pty slave.
+       (setsid): Don't detach console if the process has a pty slave.
+
 Fri Aug 24  8:54:00 2001  Corinna Vinschen <corinna@vinschen.de>
 
        * net.cc (free_addr_list): Add define for symmetry.
index 4708cb04df321151db398b98eb465d3baa98eefa..ca76b07a954968029a64aaaad2ef40dac3e576dc 100644 (file)
@@ -65,6 +65,22 @@ close_all_files (void)
   cygwin_shared->delqueue.process_queue ();
 }
 
+static BOOL __stdcall
+check_ttys_fds (void)
+{
+  int res = FALSE;
+  SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "close_all_files");
+  fhandler_base *fh;
+  for (int i = 0; i < (int) cygheap->fdtab.size; i++)
+    if ((fh = cygheap->fdtab[i]) != NULL && fh->get_device() == FH_TTYS)
+      {
+       res = TRUE;
+       break;
+      }
+  ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "close_all_files");
+  return res;
+}
+
 extern "C" int
 _unlink (const char *ourname)
 {
@@ -237,10 +253,11 @@ getppid ()
 extern "C" pid_t
 setsid (void)
 {
-  /* FIXME: for now */
   if (myself->pgid != _getpid ())
     {
-      if (myself->ctty == TTY_CONSOLE && !cygheap->fdtab.has_console_fds ())
+      if (myself->ctty == TTY_CONSOLE &&
+         !cygheap->fdtab.has_console_fds () &&
+         !check_ttys_fds ())
        FreeConsole ();
       myself->ctty = -1;
       myself->sid = _getpid ();
This page took 0.036417 seconds and 5 git commands to generate.