Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-08-25 21:27:31 +0400
committerChristopher Faylor <me@cgf.cx>2001-08-25 21:27:31 +0400
commite32b4e81cbab99dc756559f2ba05e61a3f210cde (patch)
treeccc81044c66df196460c880cc5bc79c60e8ff488 /winsup/cygwin/syscalls.cc
parent46f2e780812e5c5aa8214b7fbe33643703734fd5 (diff)
* 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.
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r--winsup/cygwin/syscalls.cc21
1 files changed, 19 insertions, 2 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 4708cb04d..ca76b07a9 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -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 ();