* fhandler.cc (fhandler_base_overlapped::wait_overlapped): Only raise SIGPIPE
when writing. * fhandler.h: Include "tty.h". (fhandler_termios::_tc): Rename from tc. (fhandler_termios::tc): New method. (fhandler_termios::tcinit): Remove an argument. (fhandler_termios::get_ttyp): Use method to retrieve value. (fhandler_console::console_state): Move here. (fhandler_console::dev_state): Delete. (fhandler_console::shared_console_info): Define. (fhandler_console::open_shared_console): Move this function under fhandler_console umbrella. (fhandler_console::tc): Define. Return static value. (fhandler_console::focus_aware): Accommodate deletion of dev_state. (fhandler_console): Add tty_list::get_cttyp as a friend. * fhandler_console.cc (dev_state): Redefine as a pointer within shared_console_info and change dev-> to dev. throughout. (fhandler_console::shared_console_info): Move into fhandler_console. (fhandler_console::open_shared_console): Move into fhandler_console change argument to simple bool. (enum_windows): Accommodate changes to console_state and open_shared_console. (console_unit::console_unit): Ditto. (fhandler_console::get_tty_stuff): Accommodate change to dev_state. (tty_list::get_cttyp): Accommodate change to handler_console::shared_console_info. (fhandler_console::read): Accommodate change from tc to tc (). (fhandler_console::set_input_state): Ditto. (fhandler_console::open): Accommodate tcinit argument change and change from tc to tc(). (fhandler_console::input_tcsetattr): Accomodate change from tc to tc(). (fhandler_console::input_tcsetattr): Ditto. (fhandler_console::write_normal): Ditto. (fhandler_console::init): Ditto. (fhandler_console::igncr_enabled): Ditto. * fhandler_termios.cc (fhandler_termios::tcinit): Remove first argument. Expect tc() to have been set up first. Use tc() rather than tc. (fhandler_termios::tcsetpgrp): Accomodate change from tc to tc(). (fhandler_termios::tcgetpgrp): Ditto. (fhandler_termios::bg_check): Ditto. (fhandler_termios::line_edit: Ditto. (fhandler_tty_master::set_winsize): Ditto. (fhandler_tty_slave::open): Ditto. (fhandler_tty_slave::init): Ditto. (fhandler_pty_master::write): Ditto. (fhandler_pty_master::setup): Ditto. Accommodate change in arguments to tcinit. (fhandler_tty_slave::fch_open_handles): Set _tc directly. (tty_min::is_orphaned_process_group): Don't assume that parent pid exists. * pinfo.cc (_pinfo::set_ctty): Reset myself->{pgid,sid} here if we were started by a non-Cygwin process but the tty exists. * shared_info.h (console_state): Delete from here. * tty.h: Make multiple inclusion safe.
This commit is contained in:
parent
0e36228bfb
commit
32bf308231
|
@ -1,3 +1,61 @@
|
||||||
|
2011-06-03 Christopher Faylor <me.cygwin2011@cgf.cx>
|
||||||
|
|
||||||
|
* fhandler.cc (fhandler_base_overlapped::wait_overlapped): Only raise
|
||||||
|
SIGPIPE when writing.
|
||||||
|
|
||||||
|
* fhandler.h: Include "tty.h".
|
||||||
|
(fhandler_termios::_tc): Rename from tc.
|
||||||
|
(fhandler_termios::tc): New method.
|
||||||
|
(fhandler_termios::tcinit): Remove an argument.
|
||||||
|
(fhandler_termios::get_ttyp): Use method to retrieve value.
|
||||||
|
(fhandler_console::console_state): Move here.
|
||||||
|
(fhandler_console::dev_state): Delete.
|
||||||
|
(fhandler_console::shared_console_info): Define.
|
||||||
|
(fhandler_console::open_shared_console): Move this function under
|
||||||
|
fhandler_console umbrella.
|
||||||
|
(fhandler_console::tc): Define. Return static value.
|
||||||
|
(fhandler_console::focus_aware): Accommodate deletion of dev_state.
|
||||||
|
(fhandler_console): Add tty_list::get_cttyp as a friend.
|
||||||
|
* fhandler_console.cc (dev_state): Redefine as a pointer within
|
||||||
|
shared_console_info and change dev-> to dev. throughout.
|
||||||
|
(fhandler_console::shared_console_info): Move into fhandler_console.
|
||||||
|
(fhandler_console::open_shared_console): Move into fhandler_console
|
||||||
|
change argument to simple bool.
|
||||||
|
(enum_windows): Accommodate changes to console_state and
|
||||||
|
open_shared_console.
|
||||||
|
(console_unit::console_unit): Ditto.
|
||||||
|
(fhandler_console::get_tty_stuff): Accommodate change to dev_state.
|
||||||
|
(tty_list::get_cttyp): Accommodate change to
|
||||||
|
handler_console::shared_console_info.
|
||||||
|
(fhandler_console::read): Accommodate change from tc to tc ().
|
||||||
|
(fhandler_console::set_input_state): Ditto.
|
||||||
|
(fhandler_console::open): Accommodate tcinit argument change and change
|
||||||
|
from tc to tc().
|
||||||
|
(fhandler_console::input_tcsetattr): Accomodate change from tc to tc().
|
||||||
|
(fhandler_console::input_tcsetattr): Ditto.
|
||||||
|
(fhandler_console::write_normal): Ditto.
|
||||||
|
(fhandler_console::init): Ditto.
|
||||||
|
(fhandler_console::igncr_enabled): Ditto.
|
||||||
|
* fhandler_termios.cc (fhandler_termios::tcinit): Remove first argument.
|
||||||
|
Expect tc() to have been set up first. Use tc() rather than tc.
|
||||||
|
(fhandler_termios::tcsetpgrp): Accomodate change from tc to tc().
|
||||||
|
(fhandler_termios::tcgetpgrp): Ditto.
|
||||||
|
(fhandler_termios::bg_check): Ditto.
|
||||||
|
(fhandler_termios::line_edit: Ditto.
|
||||||
|
(fhandler_tty_master::set_winsize): Ditto.
|
||||||
|
(fhandler_tty_slave::open): Ditto.
|
||||||
|
(fhandler_tty_slave::init): Ditto.
|
||||||
|
(fhandler_pty_master::write): Ditto.
|
||||||
|
(fhandler_pty_master::setup): Ditto. Accommodate change in arguments
|
||||||
|
to tcinit.
|
||||||
|
(fhandler_tty_slave::fch_open_handles): Set _tc directly.
|
||||||
|
(tty_min::is_orphaned_process_group): Don't assume that parent pid
|
||||||
|
exists.
|
||||||
|
* pinfo.cc (_pinfo::set_ctty): Reset myself->{pgid,sid} here if we were
|
||||||
|
started by a non-Cygwin process but the tty exists.
|
||||||
|
* shared_info.h (console_state): Delete from here.
|
||||||
|
* tty.h: Make multiple inclusion safe.
|
||||||
|
|
||||||
2011-05-31 Christopher Faylor <me.cygwin2011@cgf.cx>
|
2011-05-31 Christopher Faylor <me.cygwin2011@cgf.cx>
|
||||||
|
|
||||||
* exceptions.cc (ctrl_c_handler): Simplify test for no parent tty.
|
* exceptions.cc (ctrl_c_handler): Simplify test for no parent tty.
|
||||||
|
|
|
@ -1883,13 +1883,15 @@ fhandler_base_overlapped::wait_overlapped (bool inres, bool writing, DWORD *byte
|
||||||
debug_printf ("EOF");
|
debug_printf ("EOF");
|
||||||
*bytes = 0;
|
*bytes = 0;
|
||||||
res = overlapped_success;
|
res = overlapped_success;
|
||||||
|
if (writing && err == ERROR_BROKEN_PIPE)
|
||||||
|
raise (SIGPIPE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
debug_printf ("res %u, err %u", (unsigned) res, err);
|
debug_printf ("res %u, err %u", (unsigned) res, err);
|
||||||
*bytes = (DWORD) -1;
|
*bytes = (DWORD) -1;
|
||||||
__seterrno_from_win_error (err);
|
__seterrno_from_win_error (err);
|
||||||
if (writing && (err == ERROR_NO_DATA || err == ERROR_BROKEN_PIPE))
|
if (writing && err == ERROR_NO_DATA)
|
||||||
raise (SIGPIPE);
|
raise (SIGPIPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ details. */
|
||||||
#ifndef _FHANDLER_H_
|
#ifndef _FHANDLER_H_
|
||||||
#define _FHANDLER_H_
|
#define _FHANDLER_H_
|
||||||
|
|
||||||
|
#include "tty.h"
|
||||||
/* fcntl flags used only internaly. */
|
/* fcntl flags used only internaly. */
|
||||||
#define O_NOSYMLINK 0x080000
|
#define O_NOSYMLINK 0x080000
|
||||||
#define O_DIROPEN 0x100000
|
#define O_DIROPEN 0x100000
|
||||||
|
@ -925,7 +926,8 @@ class fhandler_termios: public fhandler_base
|
||||||
virtual void doecho (const void *, DWORD) {};
|
virtual void doecho (const void *, DWORD) {};
|
||||||
virtual int accept_input () {return 1;};
|
virtual int accept_input () {return 1;};
|
||||||
public:
|
public:
|
||||||
tty_min *tc;
|
tty_min *_tc;
|
||||||
|
virtual tty_min *tc () const {return _tc; }
|
||||||
fhandler_termios () :
|
fhandler_termios () :
|
||||||
fhandler_base ()
|
fhandler_base ()
|
||||||
{
|
{
|
||||||
|
@ -934,9 +936,9 @@ class fhandler_termios: public fhandler_base
|
||||||
HANDLE& get_output_handle () { return output_handle; }
|
HANDLE& get_output_handle () { return output_handle; }
|
||||||
line_edit_status line_edit (const char *rptr, int nread, termios&);
|
line_edit_status line_edit (const char *rptr, int nread, termios&);
|
||||||
void set_output_handle (HANDLE h) { output_handle = h; }
|
void set_output_handle (HANDLE h) { output_handle = h; }
|
||||||
void tcinit (tty_min *this_tc, bool force);
|
void tcinit (bool force);
|
||||||
bool is_tty () const { return true; }
|
bool is_tty () const { return true; }
|
||||||
tty *get_ttyp () { return (tty *) tc; }
|
tty *get_ttyp () { return (tty *) tc (); }
|
||||||
void sigflush ();
|
void sigflush ();
|
||||||
int tcgetpgrp ();
|
int tcgetpgrp ();
|
||||||
int tcsetpgrp (int pid);
|
int tcsetpgrp (int pid);
|
||||||
|
@ -1041,9 +1043,15 @@ class dev_console
|
||||||
/* This is a input and output console handle */
|
/* This is a input and output console handle */
|
||||||
class fhandler_console: public fhandler_termios
|
class fhandler_console: public fhandler_termios
|
||||||
{
|
{
|
||||||
private:
|
public:
|
||||||
|
struct console_state
|
||||||
|
{
|
||||||
|
tty_min tty_min_state;
|
||||||
|
dev_console dev_state;
|
||||||
|
};
|
||||||
|
private:
|
||||||
static const unsigned MAX_WRITE_CHARS;
|
static const unsigned MAX_WRITE_CHARS;
|
||||||
static dev_console *dev_state;
|
static console_state *shared_console_info;
|
||||||
static bool invisible_console;
|
static bool invisible_console;
|
||||||
|
|
||||||
/* Used when we encounter a truncated multi-byte sequence. The
|
/* Used when we encounter a truncated multi-byte sequence. The
|
||||||
|
@ -1075,9 +1083,16 @@ class fhandler_console: public fhandler_termios
|
||||||
void set_cursor_maybe ();
|
void set_cursor_maybe ();
|
||||||
static bool create_invisible_console (HWINSTA);
|
static bool create_invisible_console (HWINSTA);
|
||||||
static bool create_invisible_console_workaround ();
|
static bool create_invisible_console_workaround ();
|
||||||
|
static console_state *open_shared_console (HWND, HANDLE&, bool&);
|
||||||
|
tty_min *tc () const {return &(shared_console_info->tty_min_state);}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
fhandler_console ();
|
fhandler_console ();
|
||||||
|
static console_state *open_shared_console (HWND hw, HANDLE& h)
|
||||||
|
{
|
||||||
|
bool createit = false;
|
||||||
|
return open_shared_console (hw, h, createit);
|
||||||
|
}
|
||||||
|
|
||||||
fhandler_console* is_console () { return this; }
|
fhandler_console* is_console () { return this; }
|
||||||
|
|
||||||
|
@ -1098,7 +1113,7 @@ class fhandler_console: public fhandler_termios
|
||||||
int ioctl (unsigned int cmd, void *);
|
int ioctl (unsigned int cmd, void *);
|
||||||
int init (HANDLE, DWORD, mode_t);
|
int init (HANDLE, DWORD, mode_t);
|
||||||
bool mouse_aware (MOUSE_EVENT_RECORD& mouse_event);
|
bool mouse_aware (MOUSE_EVENT_RECORD& mouse_event);
|
||||||
bool focus_aware () {return dev_state->use_focus;}
|
bool focus_aware () {return shared_console_info->dev_state.use_focus;}
|
||||||
|
|
||||||
select_record *select_read (select_stuff *);
|
select_record *select_read (select_stuff *);
|
||||||
select_record *select_write (select_stuff *);
|
select_record *select_write (select_stuff *);
|
||||||
|
@ -1114,6 +1129,7 @@ class fhandler_console: public fhandler_termios
|
||||||
static bool need_invisible ();
|
static bool need_invisible ();
|
||||||
static bool has_a () {return !invisible_console;}
|
static bool has_a () {return !invisible_console;}
|
||||||
size_t size () const { return sizeof (*this);}
|
size_t size () const { return sizeof (*this);}
|
||||||
|
friend tty_min * tty_list::get_cttyp ();
|
||||||
};
|
};
|
||||||
|
|
||||||
class fhandler_tty_common: public fhandler_termios
|
class fhandler_tty_common: public fhandler_termios
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -24,49 +24,47 @@ details. */
|
||||||
/* Common functions shared by tty/console */
|
/* Common functions shared by tty/console */
|
||||||
|
|
||||||
void
|
void
|
||||||
fhandler_termios::tcinit (tty_min *this_tc, bool is_pty_master)
|
fhandler_termios::tcinit (bool is_pty_master)
|
||||||
{
|
{
|
||||||
/* Initial termios values */
|
/* Initial termios values */
|
||||||
|
|
||||||
tc = this_tc;
|
if (is_pty_master || !tc ()->initialized ())
|
||||||
|
|
||||||
if (is_pty_master || !tc->initialized ())
|
|
||||||
{
|
{
|
||||||
tc->ti.c_iflag = BRKINT | ICRNL | IXON;
|
tc ()->ti.c_iflag = BRKINT | ICRNL | IXON;
|
||||||
tc->ti.c_oflag = OPOST | ONLCR;
|
tc ()->ti.c_oflag = OPOST | ONLCR;
|
||||||
tc->ti.c_cflag = B38400 | CS8 | CREAD;
|
tc ()->ti.c_cflag = B38400 | CS8 | CREAD;
|
||||||
tc->ti.c_lflag = ISIG | ICANON | ECHO | IEXTEN;
|
tc ()->ti.c_lflag = ISIG | ICANON | ECHO | IEXTEN;
|
||||||
|
|
||||||
tc->ti.c_cc[VDISCARD] = CFLUSH;
|
tc ()->ti.c_cc[VDISCARD] = CFLUSH;
|
||||||
tc->ti.c_cc[VEOL] = CEOL;
|
tc ()->ti.c_cc[VEOL] = CEOL;
|
||||||
tc->ti.c_cc[VEOL2] = CEOL2;
|
tc ()->ti.c_cc[VEOL2] = CEOL2;
|
||||||
tc->ti.c_cc[VEOF] = CEOF;
|
tc ()->ti.c_cc[VEOF] = CEOF;
|
||||||
tc->ti.c_cc[VERASE] = CERASE;
|
tc ()->ti.c_cc[VERASE] = CERASE;
|
||||||
tc->ti.c_cc[VINTR] = CINTR;
|
tc ()->ti.c_cc[VINTR] = CINTR;
|
||||||
tc->ti.c_cc[VKILL] = CKILL;
|
tc ()->ti.c_cc[VKILL] = CKILL;
|
||||||
tc->ti.c_cc[VLNEXT] = CLNEXT;
|
tc ()->ti.c_cc[VLNEXT] = CLNEXT;
|
||||||
tc->ti.c_cc[VMIN] = 1;
|
tc ()->ti.c_cc[VMIN] = 1;
|
||||||
tc->ti.c_cc[VQUIT] = CQUIT;
|
tc ()->ti.c_cc[VQUIT] = CQUIT;
|
||||||
tc->ti.c_cc[VREPRINT] = CRPRNT;
|
tc ()->ti.c_cc[VREPRINT] = CRPRNT;
|
||||||
tc->ti.c_cc[VSTART] = CSTART;
|
tc ()->ti.c_cc[VSTART] = CSTART;
|
||||||
tc->ti.c_cc[VSTOP] = CSTOP;
|
tc ()->ti.c_cc[VSTOP] = CSTOP;
|
||||||
tc->ti.c_cc[VSUSP] = CSUSP;
|
tc ()->ti.c_cc[VSUSP] = CSUSP;
|
||||||
tc->ti.c_cc[VSWTC] = CSWTCH;
|
tc ()->ti.c_cc[VSWTC] = CSWTCH;
|
||||||
tc->ti.c_cc[VTIME] = 0;
|
tc ()->ti.c_cc[VTIME] = 0;
|
||||||
tc->ti.c_cc[VWERASE] = CWERASE;
|
tc ()->ti.c_cc[VWERASE] = CWERASE;
|
||||||
|
|
||||||
tc->ti.c_ispeed = tc->ti.c_ospeed = B38400;
|
tc ()->ti.c_ispeed = tc ()->ti.c_ospeed = B38400;
|
||||||
tc->pgid = is_pty_master ? 0 : myself->pgid;
|
tc ()->pgid = is_pty_master ? 0 : myself->pgid;
|
||||||
tc->initialized (true);
|
tc ()->initialized (true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fhandler_termios::tcsetpgrp (const pid_t pgid)
|
fhandler_termios::tcsetpgrp (const pid_t pgid)
|
||||||
{
|
{
|
||||||
termios_printf ("tty %d pgid %d, sid %d, tsid %d", tc->ntty, pgid,
|
termios_printf ("tty %d pgid %d, sid %d, tsid %d", tc ()->ntty, pgid,
|
||||||
myself->sid, tc->getsid ());
|
myself->sid, tc ()->getsid ());
|
||||||
if (myself->sid != tc->getsid ())
|
if (myself->sid != tc ()->getsid ())
|
||||||
{
|
{
|
||||||
set_errno (EPERM);
|
set_errno (EPERM);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -79,8 +77,8 @@ fhandler_termios::tcsetpgrp (const pid_t pgid)
|
||||||
switch (res)
|
switch (res)
|
||||||
{
|
{
|
||||||
case bg_ok:
|
case bg_ok:
|
||||||
tc->setpgid (pgid);
|
tc ()->setpgid (pgid);
|
||||||
init_console_handler (tc->gethwnd ());
|
init_console_handler (tc ()->gethwnd ());
|
||||||
res = 0;
|
res = 0;
|
||||||
break;
|
break;
|
||||||
case bg_signalled:
|
case bg_signalled:
|
||||||
|
@ -100,8 +98,8 @@ fhandler_termios::tcsetpgrp (const pid_t pgid)
|
||||||
int
|
int
|
||||||
fhandler_termios::tcgetpgrp ()
|
fhandler_termios::tcgetpgrp ()
|
||||||
{
|
{
|
||||||
if (myself->ctty != -1 && myself->ctty == tc->ntty)
|
if (myself->ctty != -1 && myself->ctty == tc ()->ntty)
|
||||||
return tc->pgid;
|
return tc ()->pgid;
|
||||||
set_errno (ENOTTY);
|
set_errno (ENOTTY);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -109,27 +107,7 @@ fhandler_termios::tcgetpgrp ()
|
||||||
int
|
int
|
||||||
fhandler_pty_master::tcgetpgrp ()
|
fhandler_pty_master::tcgetpgrp ()
|
||||||
{
|
{
|
||||||
return tc->pgid;
|
return tc ()->pgid;
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
tty_min::is_orphaned_process_group (int pgid)
|
|
||||||
{
|
|
||||||
/* An orphaned process group is a process group in which the parent
|
|
||||||
of every member is either itself a member of the group or is not
|
|
||||||
a member of the group's session. */
|
|
||||||
winpids pids ((DWORD) PID_MAP_RW);
|
|
||||||
for (unsigned i = 0; i < pids.npids; i++)
|
|
||||||
{
|
|
||||||
_pinfo *p = pids[i];
|
|
||||||
if (!p->exists () || p->pgid != pgid)
|
|
||||||
continue;
|
|
||||||
pinfo ppid (p->ppid);
|
|
||||||
if (ppid->pgid != pgid &&
|
|
||||||
ppid->sid == myself->sid)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -154,21 +132,45 @@ tty_min::kill_pgrp (int sig)
|
||||||
sig_send (myself, si);
|
sig_send (myself, si);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
tty_min::is_orphaned_process_group (int pgid)
|
||||||
|
{
|
||||||
|
/* An orphaned process group is a process group in which the parent
|
||||||
|
of every member is either itself a member of the group or is not
|
||||||
|
a member of the group's session. */
|
||||||
|
termios_printf ("checking pgid %d, my sid %d, my parent %d", pgid, myself->sid, myself->ppid);
|
||||||
|
winpids pids ((DWORD) 0);
|
||||||
|
for (unsigned i = 0; i < pids.npids; i++)
|
||||||
|
{
|
||||||
|
_pinfo *p = pids[i];
|
||||||
|
termios_printf ("checking pid %d - has pgid %d\n", p->pid, p->pgid);
|
||||||
|
if (!p || !p->exists () || p->pgid != pgid)
|
||||||
|
continue;
|
||||||
|
pinfo ppid (p->ppid);
|
||||||
|
if (!ppid)
|
||||||
|
continue;
|
||||||
|
termios_printf ("ppid->pgid %d, ppid->sid %d", ppid->pgid, ppid->sid);
|
||||||
|
if (ppid->pgid != pgid && ppid->sid == myself->sid)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
bg_check_types
|
bg_check_types
|
||||||
fhandler_termios::bg_check (int sig)
|
fhandler_termios::bg_check (int sig)
|
||||||
{
|
{
|
||||||
if (!myself->pgid || tc->getpgid () == myself->pgid ||
|
if (!myself->pgid || tc ()->getpgid () == myself->pgid ||
|
||||||
myself->ctty != tc->ntty ||
|
myself->ctty != tc ()->ntty ||
|
||||||
((sig == SIGTTOU) && !(tc->ti.c_lflag & TOSTOP)))
|
((sig == SIGTTOU) && !(tc ()->ti.c_lflag & TOSTOP)))
|
||||||
return bg_ok;
|
return bg_ok;
|
||||||
|
|
||||||
if (sig < 0)
|
if (sig < 0)
|
||||||
sig = -sig;
|
sig = -sig;
|
||||||
|
|
||||||
termios_printf ("bg I/O pgid %d, tpgid %d, %s, ntty %s", myself->pgid, tc->getpgid (),
|
termios_printf ("bg I/O pgid %d, tpgid %d, %s, ntty %s", myself->pgid, tc ()->getpgid (),
|
||||||
myctty (), tc->ttyname ());
|
myctty (), tc ()->ttyname ());
|
||||||
|
|
||||||
if (tc->getsid () == 0)
|
if (tc ()->getsid () == 0)
|
||||||
{
|
{
|
||||||
/* The pty has been closed by the master. Return an EOF
|
/* The pty has been closed by the master. Return an EOF
|
||||||
indication. FIXME: There is nothing to stop somebody
|
indication. FIXME: There is nothing to stop somebody
|
||||||
|
@ -188,7 +190,7 @@ fhandler_termios::bg_check (int sig)
|
||||||
process is orphaned, in which case we return EIO). */
|
process is orphaned, in which case we return EIO). */
|
||||||
if (sigs_ignored)
|
if (sigs_ignored)
|
||||||
return bg_ok; /* Just allow the IO */
|
return bg_ok; /* Just allow the IO */
|
||||||
else if ( tc->is_orphaned_process_group (myself->pgid) )
|
else if (tc ()->is_orphaned_process_group (myself->pgid))
|
||||||
{
|
{
|
||||||
termios_printf ("process group is orphaned");
|
termios_printf ("process group is orphaned");
|
||||||
set_errno (EIO); /* This is an IO error */
|
set_errno (EIO); /* This is an IO error */
|
||||||
|
@ -214,7 +216,7 @@ fhandler_termios::bg_check (int sig)
|
||||||
inline void
|
inline void
|
||||||
fhandler_termios::echo_erase (int force)
|
fhandler_termios::echo_erase (int force)
|
||||||
{
|
{
|
||||||
if (force || tc->ti.c_lflag & ECHO)
|
if (force || tc ()->ti.c_lflag & ECHO)
|
||||||
doecho ("\b \b", 3);
|
doecho ("\b \b", 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +271,7 @@ fhandler_termios::line_edit (const char *rptr, int nread, termios& ti)
|
||||||
|
|
||||||
termios_printf ("got interrupt %d, sending signal %d", c, sig);
|
termios_printf ("got interrupt %d, sending signal %d", c, sig);
|
||||||
eat_readahead (-1);
|
eat_readahead (-1);
|
||||||
tc->kill_pgrp (sig);
|
tc ()->kill_pgrp (sig);
|
||||||
ti.c_lflag &= ~FLUSHO;
|
ti.c_lflag &= ~FLUSHO;
|
||||||
sawsig = true;
|
sawsig = true;
|
||||||
goto restart_output;
|
goto restart_output;
|
||||||
|
@ -279,9 +281,9 @@ fhandler_termios::line_edit (const char *rptr, int nread, termios& ti)
|
||||||
{
|
{
|
||||||
if (CCEQ (ti.c_cc[VSTOP], c))
|
if (CCEQ (ti.c_cc[VSTOP], c))
|
||||||
{
|
{
|
||||||
if (!tc->output_stopped)
|
if (!tc ()->output_stopped)
|
||||||
{
|
{
|
||||||
tc->output_stopped = 1;
|
tc ()->output_stopped = 1;
|
||||||
acquire_output_mutex (INFINITE);
|
acquire_output_mutex (INFINITE);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -289,11 +291,11 @@ fhandler_termios::line_edit (const char *rptr, int nread, termios& ti)
|
||||||
else if (CCEQ (ti.c_cc[VSTART], c))
|
else if (CCEQ (ti.c_cc[VSTART], c))
|
||||||
{
|
{
|
||||||
restart_output:
|
restart_output:
|
||||||
tc->output_stopped = 0;
|
tc ()->output_stopped = 0;
|
||||||
release_output_mutex ();
|
release_output_mutex ();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if ((ti.c_iflag & IXANY) && tc->output_stopped)
|
else if ((ti.c_iflag & IXANY) && tc ()->output_stopped)
|
||||||
goto restart_output;
|
goto restart_output;
|
||||||
}
|
}
|
||||||
if (iscanon && ti.c_lflag & IEXTEN && CCEQ (ti.c_cc[VDISCARD], c))
|
if (iscanon && ti.c_lflag & IEXTEN && CCEQ (ti.c_cc[VDISCARD], c))
|
||||||
|
|
|
@ -68,7 +68,7 @@ fhandler_tty_master::set_winsize (bool sendSIGWINCH)
|
||||||
console->ioctl (TIOCGWINSZ, &w);
|
console->ioctl (TIOCGWINSZ, &w);
|
||||||
get_ttyp ()->winsize = w;
|
get_ttyp ()->winsize = w;
|
||||||
if (sendSIGWINCH)
|
if (sendSIGWINCH)
|
||||||
tc->kill_pgrp (SIGWINCH);
|
tc ()->kill_pgrp (SIGWINCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -493,7 +493,9 @@ fhandler_tty_slave::open (int flags, mode_t)
|
||||||
for (HANDLE **h = handles; *h; h++)
|
for (HANDLE **h = handles; *h; h++)
|
||||||
**h = NULL;
|
**h = NULL;
|
||||||
|
|
||||||
tcinit (cygwin_shared->tty[get_unit ()], false);
|
_tc = cygwin_shared->tty[get_unit ()];
|
||||||
|
|
||||||
|
tcinit (false);
|
||||||
|
|
||||||
cygwin_shared->tty.attach (get_unit ());
|
cygwin_shared->tty.attach (get_unit ());
|
||||||
|
|
||||||
|
@ -716,7 +718,7 @@ fhandler_tty_slave::init (HANDLE h, DWORD a, mode_t)
|
||||||
tty process group leader.
|
tty process group leader.
|
||||||
TODO: Investigate how SIGTTIN should be handled with pure-windows
|
TODO: Investigate how SIGTTIN should be handled with pure-windows
|
||||||
programs. */
|
programs. */
|
||||||
pinfo p (tc->getpgid ());
|
pinfo p (tc ()->getpgid ());
|
||||||
/* We should only grab this when the process group owner for this
|
/* We should only grab this when the process group owner for this
|
||||||
tty is a non-cygwin process or we've been started directly
|
tty is a non-cygwin process or we've been started directly
|
||||||
from a non-Cygwin process with no Cygwin ancestry. */
|
from a non-Cygwin process with no Cygwin ancestry. */
|
||||||
|
@ -724,7 +726,7 @@ fhandler_tty_slave::init (HANDLE h, DWORD a, mode_t)
|
||||||
{
|
{
|
||||||
termios_printf ("Setting process group leader to %d since %W(%d) is not a cygwin process",
|
termios_printf ("Setting process group leader to %d since %W(%d) is not a cygwin process",
|
||||||
myself->pgid, p->progname, p->pid);
|
myself->pgid, p->progname, p->pid);
|
||||||
tc->setpgid (myself->pgid);
|
tc ()->setpgid (myself->pgid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1248,7 +1250,7 @@ fhandler_tty_slave::fch_open_handles ()
|
||||||
{
|
{
|
||||||
char buf[MAX_PATH];
|
char buf[MAX_PATH];
|
||||||
|
|
||||||
tc = cygwin_shared->tty[get_unit ()];
|
_tc = cygwin_shared->tty[get_unit ()];
|
||||||
shared_name (buf, INPUT_AVAILABLE_EVENT, get_unit ());
|
shared_name (buf, INPUT_AVAILABLE_EVENT, get_unit ());
|
||||||
input_available_event = OpenEvent (READ_CONTROL | WRITE_DAC | WRITE_OWNER,
|
input_available_event = OpenEvent (READ_CONTROL | WRITE_DAC | WRITE_OWNER,
|
||||||
TRUE, buf);
|
TRUE, buf);
|
||||||
|
@ -1496,7 +1498,7 @@ fhandler_pty_master::write (const void *ptr, size_t len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *p = (char *) ptr;
|
char *p = (char *) ptr;
|
||||||
termios ti = tc->ti;
|
termios ti = tc ()->ti;
|
||||||
|
|
||||||
bg_check_types bg = bg_check (SIGTTOU);
|
bg_check_types bg = bg_check (SIGTTOU);
|
||||||
if (bg <= bg_eof)
|
if (bg <= bg_eof)
|
||||||
|
@ -1796,8 +1798,9 @@ fhandler_pty_master::setup (bool ispty)
|
||||||
SECURITY_ATTRIBUTES sa = { sizeof (SECURITY_ATTRIBUTES), NULL, TRUE };
|
SECURITY_ATTRIBUTES sa = { sizeof (SECURITY_ATTRIBUTES), NULL, TRUE };
|
||||||
|
|
||||||
tty& t = *cygwin_shared->tty[get_unit ()];
|
tty& t = *cygwin_shared->tty[get_unit ()];
|
||||||
|
_tc = (tty_min *)&t;
|
||||||
|
|
||||||
tcinit (&t, true); /* Set termios information. Force initialization. */
|
tcinit (true); /* Set termios information. Force initialization. */
|
||||||
|
|
||||||
const char *errstr = NULL;
|
const char *errstr = NULL;
|
||||||
DWORD pipe_mode = PIPE_NOWAIT;
|
DWORD pipe_mode = PIPE_NOWAIT;
|
||||||
|
|
|
@ -403,6 +403,12 @@ _pinfo::set_ctty (tty_min *tc, int flags, fhandler_termios *fh)
|
||||||
lock_ttys here;
|
lock_ttys here;
|
||||||
syscall_printf ("attaching %s sid %d, pid %d, pgid %d, tty->pgid %d, tty->sid %d",
|
syscall_printf ("attaching %s sid %d, pid %d, pgid %d, tty->pgid %d, tty->sid %d",
|
||||||
__ctty (), sid, pid, pgid, tc->getpgid (), tc->getsid ());
|
__ctty (), sid, pid, pgid, tc->getpgid (), tc->getsid ());
|
||||||
|
if (!cygwin_finished_initializing && !myself->cygstarted
|
||||||
|
&& myself->pgid == myself->pid)
|
||||||
|
{
|
||||||
|
myself->pgid = tc->getpgid ();
|
||||||
|
myself->sid = tc->getsid ();
|
||||||
|
}
|
||||||
|
|
||||||
pinfo p (tc->getsid ());
|
pinfo p (tc->getsid ());
|
||||||
if (sid == pid && (!p || p->pid == pid || !p->exists ()))
|
if (sid == pid && (!p || p->pid == pid || !p->exists ()))
|
||||||
|
|
|
@ -79,14 +79,6 @@ void __stdcall shared_destroy ();
|
||||||
(((DWORD) ((p) + 1) + system_info.dwAllocationGranularity - 1) / \
|
(((DWORD) ((p) + 1) + system_info.dwAllocationGranularity - 1) / \
|
||||||
system_info.dwAllocationGranularity)))
|
system_info.dwAllocationGranularity)))
|
||||||
|
|
||||||
#ifdef _FHANDLER_H_
|
|
||||||
struct console_state
|
|
||||||
{
|
|
||||||
tty_min tty_min_state;
|
|
||||||
dev_console dev_state;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
HANDLE get_shared_parent_dir ();
|
HANDLE get_shared_parent_dir ();
|
||||||
HANDLE get_session_parent_dir ();
|
HANDLE get_session_parent_dir ();
|
||||||
char *__stdcall shared_name (char *, const char *, int);
|
char *__stdcall shared_name (char *, const char *, int);
|
||||||
|
|
|
@ -8,6 +8,8 @@ This software is a copyrighted work licensed under the terms of the
|
||||||
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
||||||
details. */
|
details. */
|
||||||
|
|
||||||
|
#ifndef _TTY_H
|
||||||
|
#define _TTY_H
|
||||||
/* tty tables */
|
/* tty tables */
|
||||||
|
|
||||||
#define INP_BUFFER_SIZE 256
|
#define INP_BUFFER_SIZE 256
|
||||||
|
@ -148,3 +150,4 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C" int ttyslot (void);
|
extern "C" int ttyslot (void);
|
||||||
|
#endif /*_TTY_H*/
|
||||||
|
|
Loading…
Reference in New Issue