From 59297e046420341bea04797159ee62b544c2295d Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Mon, 14 Nov 2005 04:28:45 +0000 Subject: [PATCH] * cygheap.h (init_cygheap::manage_console_count): Declare new function. (init_cygheap::console_count): Renamed from open_fhs. Make private. * cygheap.cc (init_cygheap::manage_console_count): Define new function. * dtable.cc (dtable::fixup_after_exec): Always call fixup_after_exec on elements of fd even when they are about to be closed. * fhandler.h (report_tty_counts): Remove open_fhs from debugging output. * fhandler_console.cc (fhandler_console::open): Use manage_console_count rather than manipulating count directly. (fhandler_console::close): Ditto. (fhandler_console::fixup_after_fork): Ditto. (fhandler_console::fixup_after_exec): Ditto. Don't close handles if close_on_exec. * fhandler_tty.cc (fhandler_tty_slave::open): Use manage_console_count() rather than manipulating count directly. Reflect change in arguments to report_tty_counts(). (fhandler_tty_slave::close): Ditto for both. (fhandler_tty_slave::dup): Ditto for both. (fhandler_tty_slave::ioctl): Use myctty() rather than raw ctty #. (fhandler_tty_slave::fixup_after_fork): Reflect change in arguments to report_tty_counts(). (fhandler_tty_master::init_console): Use manage_console_count() rather than manipulating count directly. * fhandler_clipboard.cc (fhandler_dev_clipboard::fixup_after_exec): Don't perform any operations if close_on_exec. * fhandler_dsp.cc (fhandler_dev_dsp::fixup_after_exec): Ditto. * fhandler_raw.cc (fhandler_dev_raw::fixup_after_exec): Ditto. * fhandler_serial.cc (fhandler_serial::fixup_after_exec): Ditto. * pinfo.h (_pinfo::_ctty): Declare new function. (myctty): Declare new macro. (__ctty): Declare new macro. * pinfo.cc (_pinfo::_ctty): Define new function. (_pinfo::set_ctty): Use manage_console_count() rather than manipulating count directly. * signal.cc (kill_pgrp): Use myctty() and __ctty() macros rather than raw ctty #. * syscalls.cc (setsid): Ditto. Use manage_console_count() rather than manipulating count directly. --- winsup/cygwin/ChangeLog | 41 +++++++++++++++++++++++++++++ winsup/cygwin/cygheap.cc | 14 ++++++++++ winsup/cygwin/cygheap.h | 5 +++- winsup/cygwin/dtable.cc | 15 +++++------ winsup/cygwin/fhandler.h | 5 ++-- winsup/cygwin/fhandler_clipboard.cc | 9 ++++--- winsup/cygwin/fhandler_console.cc | 28 +++++++++++--------- winsup/cygwin/fhandler_dsp.cc | 15 ++++++----- winsup/cygwin/fhandler_raw.cc | 13 +++++---- winsup/cygwin/fhandler_serial.cc | 5 ++-- winsup/cygwin/fhandler_socket.cc | 1 - winsup/cygwin/fhandler_termios.cc | 4 +-- winsup/cygwin/fhandler_tty.cc | 24 ++++++++--------- winsup/cygwin/fork.cc | 6 ++--- winsup/cygwin/pinfo.cc | 16 +++++++++-- winsup/cygwin/pinfo.h | 4 +++ winsup/cygwin/signal.cc | 4 +-- winsup/cygwin/syscalls.cc | 10 +++---- 18 files changed, 148 insertions(+), 71 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 836ad3c7d..136508f22 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,44 @@ +2005-11-13 Christopher Faylor + + * cygheap.h (init_cygheap::manage_console_count): Declare new function. + (init_cygheap::console_count): Renamed from open_fhs. Make private. + * cygheap.cc (init_cygheap::manage_console_count): Define new function. + * dtable.cc (dtable::fixup_after_exec): Always call fixup_after_exec on + elements of fd even when they are about to be closed. + * fhandler.h (report_tty_counts): Remove open_fhs from debugging + output. + * fhandler_console.cc (fhandler_console::open): Use + manage_console_count rather than manipulating count directly. + (fhandler_console::close): Ditto. + (fhandler_console::fixup_after_fork): Ditto. + (fhandler_console::fixup_after_exec): Ditto. Don't close handles if + close_on_exec. + * fhandler_tty.cc (fhandler_tty_slave::open): Use + manage_console_count() rather than manipulating count directly. + Reflect change in arguments to report_tty_counts(). + (fhandler_tty_slave::close): Ditto for both. + (fhandler_tty_slave::dup): Ditto for both. + (fhandler_tty_slave::ioctl): Use myctty() rather than raw ctty #. + (fhandler_tty_slave::fixup_after_fork): Reflect change in arguments to + report_tty_counts(). + (fhandler_tty_master::init_console): Use manage_console_count() rather + than manipulating count directly. + * fhandler_clipboard.cc (fhandler_dev_clipboard::fixup_after_exec): + Don't perform any operations if close_on_exec. + * fhandler_dsp.cc (fhandler_dev_dsp::fixup_after_exec): Ditto. + * fhandler_raw.cc (fhandler_dev_raw::fixup_after_exec): Ditto. + * fhandler_serial.cc (fhandler_serial::fixup_after_exec): Ditto. + * pinfo.h (_pinfo::_ctty): Declare new function. + (myctty): Declare new macro. + (__ctty): Declare new macro. + * pinfo.cc (_pinfo::_ctty): Define new function. + (_pinfo::set_ctty): Use manage_console_count() rather than manipulating + count directly. + * signal.cc (kill_pgrp): Use myctty() and __ctty() macros rather than + raw ctty #. + * syscalls.cc (setsid): Ditto. Use manage_console_count() rather than + manipulating count directly. + 2005-11-13 Corinna Vinschen * fhandler_socket.cc (fhandler_socket::recvfrom): Just return 0 (EOF) diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc index d7d15667c..279b7389e 100644 --- a/winsup/cygwin/cygheap.cc +++ b/winsup/cygwin/cygheap.cc @@ -90,6 +90,20 @@ cygheap_fixup_in_child (bool execed) } } +int +init_cygheap::manage_console_count (const char *something, int amount, bool avoid_freeing_console) +{ + console_count += amount; + debug_printf ("%s: console_count %d, amount %d, %s, avoid_freeing_console %d", + something, console_count, amount, myctty (), avoid_freeing_console); + if (!avoid_freeing_console && amount <= 0 && !console_count && myself->ctty == -1) + { + FreeConsole (); + debug_printf ("freed console"); + } + return console_count; +} + void init_cygheap::close_ctty () { diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h index ea4fb1c20..100d8d92d 100644 --- a/winsup/cygwin/cygheap.h +++ b/winsup/cygwin/cygheap.h @@ -296,13 +296,16 @@ struct init_cygheap #endif struct _cygtls **threadlist; size_t sthreads; - int open_fhs; pid_t pid; /* my pid */ HANDLE pid_handle; /* handle for my pid */ hook_chain hooks; void close_ctty (); + int manage_console_count (const char *, int, bool = false) __attribute__ ((regparm (3))); +private: + int console_count; }; + #define _CYGHEAPSIZE_SLOP (128 * 1024) #define CYGHEAPSIZE (sizeof (init_cygheap) + (20000 * sizeof (fhandler_union)) + _CYGHEAPSIZE_SLOP) #define CYGHEAPSIZE_MIN (sizeof (init_cygheap) + (10000 * sizeof (fhandler_union))) diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index 6f3da436d..08832a6a5 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -683,20 +683,17 @@ dtable::fixup_after_exec () if ((fh = fds[i]) != NULL) { fh->clear_readahead (); + fh->fixup_after_exec (); if (fh->close_on_exec ()) { if (fh->archetype) fh->close (); release (i); } - else - { - fh->fixup_after_exec (); - if (i == 0) - SetStdHandle (std_consts[i], fh->get_io_handle ()); - else if (i <= 2) - SetStdHandle (std_consts[i], fh->get_output_handle ()); - } + else if (i == 0) + SetStdHandle (std_consts[i], fh->get_io_handle ()); + else if (i <= 2) + SetStdHandle (std_consts[i], fh->get_output_handle ()); } } @@ -733,7 +730,7 @@ dtable::vfork_child_dup () if (cygheap->ctty) { cygheap->ctty->usecount++; - cygheap->open_fhs++; + cygheap->console_count++; report_tty_counts (cygheap->ctty, "vfork dup", "incremented ", ""); } diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index b45d82ff4..66ccf1e83 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -1261,10 +1261,9 @@ struct fhandler_nodevice: public fhandler_base // int __stdcall fstat (struct __stat64 *buf, path_conv *); }; -#define report_tty_counts(fh, call, fhs_op, use_op) \ - termios_printf ("%s %s, %sopen_fhs %d, %susecount %d",\ +#define report_tty_counts(fh, call, use_op) \ + termios_printf ("%s %s, %susecount %d",\ fh->ttyname (), call,\ - fhs_op, cygheap->open_fhs,\ use_op, ((fhandler_tty_slave *) fh)->archetype->usecount); typedef union diff --git a/winsup/cygwin/fhandler_clipboard.cc b/winsup/cygwin/fhandler_clipboard.cc index e5b6ebe5f..15ae5f936 100644 --- a/winsup/cygwin/fhandler_clipboard.cc +++ b/winsup/cygwin/fhandler_clipboard.cc @@ -276,7 +276,10 @@ fhandler_dev_clipboard::close () void fhandler_dev_clipboard::fixup_after_exec () { - eof = false; - pos = msize = 0; - membuffer = NULL; + if (!close_on_exec ()) + { + eof = false; + pos = msize = 0; + membuffer = NULL; + } } diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index f1e180a95..a8c73d618 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -678,8 +678,7 @@ fhandler_console::open (int flags, mode_t) tc->rstcons (false); set_open_status (); - cygheap->open_fhs++; - debug_printf ("incremented open_fhs, now %d", cygheap->open_fhs); + cygheap->manage_console_count ("fhandler_console::open", 1); debug_printf ("opened conin$ %p, conout$ %p", get_io_handle (), get_output_handle ()); @@ -691,12 +690,8 @@ fhandler_console::close () { CloseHandle (get_io_handle ()); CloseHandle (get_output_handle ()); - if (!hExeced && --(cygheap->open_fhs) <= 0 && myself->ctty != TTY_CONSOLE) - { - syscall_printf ("open_fhs %d", cygheap->open_fhs); - FreeConsole (); - } - debug_printf ("decremented open_fhs, now %d", cygheap->open_fhs); + if (!hExeced) + cygheap->manage_console_count ("fhandler_console::close", -1); return 0; } @@ -1771,10 +1766,13 @@ fhandler_console::fixup_after_fork (HANDLE) /* Windows does not allow duplication of console handles between processes so open the console explicitly. */ - cygheap->open_fhs--; /* The downside of storing this in cygheap. */ if (!open (O_NOCTTY | get_flags (), 0)) system_printf ("error opening console after fork, %E"); + /* Need to decrement console_count since this open is basically a no-op to reopen + the console and we've already recorded that fact. */ + cygheap->manage_console_count ("fhandler_console::fixup_after_fork", -1); + if (!close_on_exec ()) { CloseHandle (h); @@ -1802,8 +1800,9 @@ fhandler_console::fixup_after_exec () HANDLE h = get_handle (); HANDLE oh = get_output_handle (); - cygheap->open_fhs--; /* The downside of storing this in cygheap. */ - if (!open (O_NOCTTY | get_flags (), 0)) + if (close_on_exec () || open (O_NOCTTY | get_flags (), 0)) + cygheap->manage_console_count ("fhandler_console::fixup_after_exec", -1); + else { bool sawerr = false; if (!get_io_handle ()) @@ -1821,6 +1820,9 @@ fhandler_console::fixup_after_exec () system_printf ("error opening console after exec, errno %d, %E", get_errno ()); } - CloseHandle (h); - CloseHandle (oh); + if (!close_on_exec ()) + { + CloseHandle (h); + CloseHandle (oh); + } } diff --git a/winsup/cygwin/fhandler_dsp.cc b/winsup/cygwin/fhandler_dsp.cc index 3813eeef9..33a829409 100644 --- a/winsup/cygwin/fhandler_dsp.cc +++ b/winsup/cygwin/fhandler_dsp.cc @@ -1361,11 +1361,14 @@ fhandler_dev_dsp::fixup_after_fork (HANDLE parent) void fhandler_dev_dsp::fixup_after_exec () { - debug_printf ("audio_in=%08x audio_out=%08x", - (int)audio_in_, (int)audio_out_); - if (archetype != this) - return ((fhandler_dev_dsp *)archetype)->fixup_after_exec (); + debug_printf ("audio_in=%08x audio_out=%08x, close_on_exec %d", + (int) audio_in_, (int) audio_out_, close_on_exec ()); + if (!close_on_exec ()) + { + if (archetype != this) + return ((fhandler_dev_dsp *) archetype)->fixup_after_exec (); - audio_in_ = NULL; - audio_out_ = NULL; + audio_in_ = NULL; + audio_out_ = NULL; + } } diff --git a/winsup/cygwin/fhandler_raw.cc b/winsup/cygwin/fhandler_raw.cc index c5a8ab074..479515fe5 100644 --- a/winsup/cygwin/fhandler_raw.cc +++ b/winsup/cygwin/fhandler_raw.cc @@ -124,11 +124,14 @@ fhandler_dev_raw::fixup_after_fork (HANDLE) void fhandler_dev_raw::fixup_after_exec () { - if (devbufsiz > 1L) - devbuf = new char [devbufsiz]; - devbufstart = 0; - devbufend = 0; - lastblk_to_read (false); + if (!close_on_exec ()) + { + if (devbufsiz > 1L) + devbuf = new char [devbufsiz]; + devbufstart = 0; + devbufend = 0; + lastblk_to_read (false); + } } int diff --git a/winsup/cygwin/fhandler_serial.cc b/winsup/cygwin/fhandler_serial.cc index 785c8b69a..1488da21d 100644 --- a/winsup/cygwin/fhandler_serial.cc +++ b/winsup/cygwin/fhandler_serial.cc @@ -1064,8 +1064,9 @@ fhandler_serial::fixup_after_fork (HANDLE parent) void fhandler_serial::fixup_after_exec () { - overlapped_setup (); - debug_printf ("io_status.hEvent %p", io_status.hEvent); + if (!close_on_exec ()) + overlapped_setup (); + debug_printf ("io_status.hEvent %p, close_on_exec %d", io_status.hEvent, close_on_exec ()); } int diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index 5ed7d041a..ec772ff49 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -432,7 +432,6 @@ fhandler_socket::fixup_after_fork (HANDLE parent) void fhandler_socket::fixup_after_exec () { - debug_printf ("here"); if (!close_on_exec ()) fixup_after_fork (NULL); } diff --git a/winsup/cygwin/fhandler_termios.cc b/winsup/cygwin/fhandler_termios.cc index f2e1e3425..101a595fd 100644 --- a/winsup/cygwin/fhandler_termios.cc +++ b/winsup/cygwin/fhandler_termios.cc @@ -139,8 +139,8 @@ fhandler_termios::bg_check (int sig) if (sig < 0) sig = -sig; - termios_printf ("bg I/O pgid %d, tpgid %d, ctty %d", - myself->pgid, tc->getpgid (), myself->ctty); + termios_printf ("bg I/O pgid %d, tpgid %d, %s", myself->pgid, tc->getpgid (), + myctty ()); if (tc->getsid () == 0) { diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 630caedca..0afc1a0c4 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -457,7 +457,7 @@ fhandler_tty_slave::open (int flags, mode_t) *this = *(fhandler_tty_slave *) arch; termios_printf ("copied tty fhandler archetype"); set_flags ((flags & ~O_TEXT) | O_BINARY); - cygheap->open_fhs++; + cygheap->manage_console_count ("fhandler_tty_slave::open", 1); goto out; } @@ -576,7 +576,8 @@ fhandler_tty_slave::open (int flags, mode_t) set_output_handle (to_master_local); set_open_status (); - if (cygheap->open_fhs++ == 0 && !GetConsoleCP () && !output_done_event + if (cygheap->manage_console_count ("fhandler_tty_slave::open", 1) == 1 + && !GetConsoleCP () && !output_done_event && wincap.pty_needs_alloc_console () && !GetProcessWindowStation ()) { BOOL b; @@ -603,7 +604,7 @@ fhandler_tty_slave::open (int flags, mode_t) out: usecount = 0; archetype->usecount++; - report_tty_counts (this, "opened", "incremented ", ""); + report_tty_counts (this, "opened", ""); myself->set_ctty (get_ttyp (), flags, arch); return 1; @@ -614,11 +615,10 @@ fhandler_tty_slave::close () { if (!hExeced) { - if (!--cygheap->open_fhs && myself->ctty == -1) - FreeConsole (); + cygheap->manage_console_count ("fhandler_tty_slave::close", -1); archetype->usecount--; - report_tty_counts (this, "closed", "decremented ", ""); + report_tty_counts (this, "closed", ""); if (archetype->usecount) { @@ -921,8 +921,8 @@ fhandler_tty_slave::dup (fhandler_base *child) *(fhandler_tty_slave *) child = *arch; child->usecount = 0; arch->usecount++; - cygheap->open_fhs++; - report_tty_counts (child, "duped", "incremented ", ""); + cygheap->manage_console_count ("fhandler_tty_slave::dup", 1); + report_tty_counts (child, "duped", ""); myself->set_ctty (get_ttyp (), openflags, arch); return 0; } @@ -1070,8 +1070,8 @@ fhandler_tty_slave::ioctl (unsigned int cmd, void *arg) && myself->ctty == get_unit () && (get_ttyp ()->ti.c_lflag & TOSTOP)) { /* background process */ - termios_printf ("bg ioctl pgid %d, tpgid %d, ctty %d", - myself->pgid, get_ttyp ()->getpgid (), myself->ctty); + termios_printf ("bg ioctl pgid %d, tpgid %d, %s", myself->pgid, + get_ttyp ()->getpgid (), myctty ()); raise (SIGTTOU); } @@ -1389,7 +1389,7 @@ void fhandler_tty_slave::fixup_after_fork (HANDLE parent) { // fhandler_tty_common::fixup_after_fork (parent); - report_tty_counts (this, "inherited", "", ""); + report_tty_counts (this, "inherited", ""); } void @@ -1434,7 +1434,7 @@ fhandler_tty_master::init_console () return -1; console->init (INVALID_HANDLE_VALUE, GENERIC_READ | GENERIC_WRITE, O_BINARY); - cygheap->open_fhs--; /* handled when individual fds are opened */ + cygheap->manage_console_count ("fhandler_tty_master::init_console", -1, true); console->uninterruptible_io (true); return 0; } diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index 33811eccd..a9117e7c8 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -647,8 +647,8 @@ vfork () vf->sid = myself->sid; vf->pgid = myself->pgid; cygheap->ctty_on_hold = cygheap->ctty; - vf->open_fhs = cygheap->open_fhs; - debug_printf ("cygheap->ctty_on_hold %p, cygheap->open_fhs %d", cygheap->ctty_on_hold, cygheap->open_fhs); + vf->console_count = cygheap->console_count; + debug_printf ("cygheap->ctty_on_hold %p, cygheap->console_count %d", cygheap->ctty_on_hold, cygheap->console_count); int res = cygheap->fdtab.vfork_child_dup () ? 0 : -1; debug_printf ("%d = vfork()", res); _my_tls.call_signal_handler (); // FIXME: racy @@ -668,7 +668,7 @@ vfork () myself->sid = vf->sid; myself->pgid = vf->pgid; termios_printf ("cygheap->ctty %p, cygheap->ctty_on_hold %p", cygheap->ctty, cygheap->ctty_on_hold); - cygheap->open_fhs = vf->open_fhs; + cygheap->console_count = vf->console_count; if (vf->pid < 0) { diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index 098b67e41..7350a00a1 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -315,6 +315,18 @@ pinfo::set_acl() debug_printf ("SetKernelObjectSecurity %E"); } +const char * +_pinfo::_ctty (char *buf) +{ + if (ctty == TTY_CONSOLE) + strcpy (buf, "ctty /dev/console"); + else if (ctty < 0) + strcpy (buf, "no ctty"); + else + __small_sprintf (buf, "ctty /dev/tty%d", ctty); + return buf; +} + void _pinfo::set_ctty (tty_min *tc, int flags, fhandler_tty_slave *arch) { @@ -353,8 +365,8 @@ _pinfo::set_ctty (tty_min *tc, int flags, fhandler_tty_slave *arch) if (arch) { arch->usecount++; - cygheap->open_fhs++; - report_tty_counts (cygheap->ctty, "ctty", "incremented ", ""); + cygheap->manage_console_count ("pinfo::set_ctty", 1); + report_tty_counts (cygheap->ctty, "ctty", ""); } } } diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h index 2038f9b6e..d0c634909 100644 --- a/winsup/cygwin/pinfo.h +++ b/winsup/cygwin/pinfo.h @@ -119,6 +119,7 @@ public: bool alert_parent (char); int __stdcall kill (siginfo_t&) __attribute__ ((regparm (2))); bool __stdcall exists () __attribute__ ((regparm (1))); + const char *_ctty (char *); friend void __stdcall set_myself (HANDLE); @@ -240,6 +241,9 @@ extern pinfo myself; #define _P_VFORK 0 #define _P_SYSTEM 512 +#define __ctty() _ctty ((char *) alloca (sizeof ("ctty /dev/tty") + 20)) +#define myctty() myself->__ctty () + /* For mmaps across fork(). */ int __stdcall fixup_mmaps_after_fork (HANDLE parent); /* for shm areas across fork (). */ diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc index 87e16ca69..01ba0bef0 100644 --- a/winsup/cygwin/signal.cc +++ b/winsup/cygwin/signal.cc @@ -289,8 +289,8 @@ kill_pgrp (pid_t pid, siginfo_t& si) (pid > 1 && p->pgid != pid) || (si.si_signo < 0 && NOTSTATE (p, PID_STOPPED))) continue; - sigproc_printf ("killing pid %d, pgrp %d, p->ctty %d, myself->ctty %d", - p->pid, p->pgid, p->ctty, myself->ctty); + sigproc_printf ("killing pid %d, pgrp %d, p->%s, %s", p->pid, p->pgid, + p->__ctty (), myctty ()); if (p == myself) killself++; else if (p->kill (si)) diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 2cf14ef85..2a425ed0c 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -341,18 +341,14 @@ setsid (void) syscall_printf ("hmm. pgid %d pid %d", myself->pgid, myself->pid); else { - if (myself->ctty >= 0 && cygheap->open_fhs <= 0) - { - syscall_printf ("freeing console"); - FreeConsole (); - } myself->ctty = -1; + cygheap->manage_console_count ("setsid", 0); myself->sid = getpid (); myself->pgid = getpid (); if (cygheap->ctty) cygheap->close_ctty (); - syscall_printf ("sid %d, pgid %d, ctty %d, open_fhs %d", myself->sid, - myself->pgid, myself->ctty, cygheap->open_fhs); + syscall_printf ("sid %d, pgid %d, ctty %d", myself->sid, myself->pgid, + myself->ctty); return myself->sid; }