public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: pty: Disable FreeConsole() on close for non cygwin process. Date: Tue, 14 Jan 2020 16:31:00 -0000 [thread overview] Message-ID: <20200114163109.129947.qmail@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=2f415d5efae5a47906f0fdf5080c407b56b5ce20 commit 2f415d5efae5a47906f0fdf5080c407b56b5ce20 Author: Takashi Yano <takashi.yano@nifty.ne.jp> Date: Fri Jan 10 20:46:26 2020 +0900 Cygwin: pty: Disable FreeConsole() on close for non cygwin process. - After commit e1a0775dc0545b5f9c81b09a327fc110c538b7b4, the problem reported in https://www.cygwin.com/ml/cygwin/2020-01/msg00093.html occurs. For Gnu scren and tmux, calling FreeConsole() on pty close is necessary. However, if FreeConsole() is called, cygwin setup with '-h' option does not work. Therefore, the commit e1a0775dc0545b5f9c81b09a327fc110c538b7b4 delayed closing pty. This is the cause of the problem above. Now, instead of delaying pty close, FreeConsole() is not called if the process is non cygwin processes such as cygwin setup. Diff: --- winsup/cygwin/fhandler.h | 1 + winsup/cygwin/fhandler_tty.cc | 13 +++++++++++-- winsup/cygwin/spawn.cc | 6 ++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 4a71c16..c0d56b4 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -2200,6 +2200,7 @@ class fhandler_pty_slave: public fhandler_pty_common return get_ttyp ()->ti.c_lflag & ICANON; } void setup_locale (void); + void set_freeconsole_on_close (bool val); }; #define __ptsname(buf, unit) __small_sprintf ((buf), "/dev/pty%d", (unit)) diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 042ffd1..983e058 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -66,6 +66,7 @@ struct pipe_reply { static int pcon_attached_to = -1; static bool isHybrid; static bool do_not_reset_switch_to_pcon; +static bool freeconsole_on_close = true; #if USE_API_HOOK static void @@ -725,7 +726,8 @@ fhandler_pty_slave::~fhandler_pty_slave () if (used == 0) { init_console_handler (false); - FreeConsole (); + if (freeconsole_on_close) + FreeConsole (); } } } @@ -2661,6 +2663,12 @@ fhandler_pty_slave::setup_locale (void) } void +fhandler_pty_slave::set_freeconsole_on_close (bool val) +{ + freeconsole_on_close = val; +} + +void fhandler_pty_slave::fixup_after_attach (bool native_maybe, int fd_set) { if (fd < 0) @@ -2783,7 +2791,8 @@ fhandler_pty_slave::fixup_after_exec () if (used == 1 /* About to close this tty */) { init_console_handler (false); - FreeConsole (); + if (freeconsole_on_close) + FreeConsole (); } } diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 6a50342..08d52bb 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -607,6 +607,8 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv, attach_to_console = true; } ptys->fixup_after_attach (!iscygwin (), fd); + if (mode == _P_OVERLAY) + ptys->set_freeconsole_on_close (iscygwin ()); } } else if (fh && fh->get_major () == DEV_CONS_MAJOR) @@ -809,6 +811,8 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv, NtClose (old_winpid_hdl); real_path.get_wide_win32_path (myself->progname); // FIXME: race? sigproc_printf ("new process name %W", myself->progname); + if (!iscygwin ()) + close_all_files (); } else { @@ -907,8 +911,6 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv, wait_for_myself (); } myself.exit (EXITCODE_NOSET); - if (!iscygwin ()) - close_all_files (); break; case _P_WAIT: case _P_SYSTEM:
reply other threads:[~2020-01-14 16:31 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200114163109.129947.qmail@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).