Throughout, change 'tty_attached' to 'real_tty_attached', for clarity.
Throughout, change 'OutputStopped' to 'output_stopped', for consistency. * dtable.cc (stdio_init): Set controlling tty if not set by stdio opens. * exceptions.cc (ctrl_c_handler): Avoid special pgid checking if no tty is associated with the process. (Suggested by Tim Baker <dbaker@direct.ca>) * external.cc (fillout_pinfo): Return actual tty number for ctty. * fhandler_console.cc (get_tty_stuff): Set ctty when shared memory is allocated. Accept flags input from open(). (set_console_ctty): New function. (fhandler_console::open): Pass flags to get_tty_stuff and rely on this function to set the ctty, if appropriate. * fhandler_termios.cc (fhandler_termios::set_ctty): Move to tty_min class. * fhandler_tty.cc (fhandler_tty_slave::open): Use tc field to access set_ctty(). * tty.h (TTY_CONSOLE): Move to include/sys/cygwin.h. (tty_min): Add set_ctty class here. * include/sys/cygwin.h (TTY_CONSOLE): New home here. * path.cc (symlink_info): Make contents an actual buffer. Pass more flags to case_check. (path_conv::check): Reorganize to do parsing based on posix path rather than native path. (symlink_info::check): Expect posix path as input. Translate to native path here. Accept path_conv flags. Stop parsing if not a symlink regardless of whether previous path was a symlink.
This commit is contained in:
parent
0ca6697493
commit
b98ebf5470
|
@ -1,3 +1,35 @@
|
|||
Sat Apr 28 19:36:13 2001 Christopher Faylor <cgf@cygnus.com>
|
||||
|
||||
Throughout, change 'tty_attached' to 'real_tty_attached', for clarity.
|
||||
Throughout, change 'OutputStopped' to 'output_stopped', for
|
||||
consistency.
|
||||
* dtable.cc (stdio_init): Set controlling tty if not set by stdio
|
||||
opens.
|
||||
* exceptions.cc (ctrl_c_handler): Avoid special pgid checking if no tty
|
||||
is associated with the process.
|
||||
(Suggested by Tim Baker <dbaker@direct.ca>)
|
||||
* external.cc (fillout_pinfo): Return actual tty number for ctty.
|
||||
* fhandler_console.cc (get_tty_stuff): Set ctty when shared memory is
|
||||
allocated. Accept flags input from open().
|
||||
(set_console_ctty): New function.
|
||||
(fhandler_console::open): Pass flags to get_tty_stuff and rely on this
|
||||
function to set the ctty, if appropriate.
|
||||
* fhandler_termios.cc (fhandler_termios::set_ctty): Move to tty_min
|
||||
class.
|
||||
* fhandler_tty.cc (fhandler_tty_slave::open): Use tc field to access
|
||||
set_ctty().
|
||||
* tty.h (TTY_CONSOLE): Move to include/sys/cygwin.h.
|
||||
(tty_min): Add set_ctty class here.
|
||||
* include/sys/cygwin.h (TTY_CONSOLE): New home here.
|
||||
|
||||
* path.cc (symlink_info): Make contents an actual buffer. Pass more
|
||||
flags to case_check.
|
||||
(path_conv::check): Reorganize to do parsing based on posix path rather
|
||||
than native path.
|
||||
(symlink_info::check): Expect posix path as input. Translate to native
|
||||
path here. Accept path_conv flags. Stop parsing if not a symlink
|
||||
regardless of whether previous path was a symlink.
|
||||
|
||||
2001-04-27 Kazuhiro Fujieda <fujieda@jaist.ac.jp>
|
||||
|
||||
* thread.cc (thread_init_wrapper): Use _REENT_INIT to initialize the
|
||||
|
|
|
@ -1034,7 +1034,7 @@ do_exit (int status)
|
|||
}
|
||||
|
||||
/* Kill the foreground process group on session leader exit */
|
||||
if (getpgrp () > 0 && myself->pid == myself->sid && tty_attached (myself))
|
||||
if (getpgrp () > 0 && myself->pid == myself->sid && real_tty_attached (myself))
|
||||
{
|
||||
tty *tp = cygwin_shared->tty[myself->ctty];
|
||||
sigproc_printf ("%d == sid %d, send SIGHUP to children",
|
||||
|
|
|
@ -87,6 +87,7 @@ dtable::extend (int howmuch)
|
|||
void
|
||||
stdio_init (void)
|
||||
{
|
||||
extern void set_console_ctty ();
|
||||
/* Set these before trying to output anything from strace.
|
||||
Also, always set them even if we're to pick up our parent's fds
|
||||
in case they're missed. */
|
||||
|
@ -117,6 +118,10 @@ stdio_init (void)
|
|||
|
||||
cygheap->fdtab.init_std_file_from_handle (1, out, GENERIC_WRITE, "{stdout}");
|
||||
cygheap->fdtab.init_std_file_from_handle (2, err, GENERIC_WRITE, "{stderr}");
|
||||
/* Assign the console as the controlling tty for this process if we actually
|
||||
have a console and no other controlling tty has been assigned. */
|
||||
if (myself->ctty < 0 && GetConsoleCP () > 0)
|
||||
set_console_ctty ();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -890,7 +890,7 @@ setup_handler (int sig, void *handler, struct sigaction& siga)
|
|||
#error "Need to supply machine dependent setup_handler"
|
||||
#endif
|
||||
|
||||
/* Keyboard interrupt handler. */
|
||||
/* CGF Keyboard interrupt handler. */
|
||||
static BOOL WINAPI
|
||||
ctrl_c_handler (DWORD type)
|
||||
{
|
||||
|
@ -908,7 +908,7 @@ ctrl_c_handler (DWORD type)
|
|||
tty_min *t = cygwin_shared->tty.get_tty (myself->ctty);
|
||||
/* Ignore this if we're not the process group lead since it should be handled
|
||||
*by* the process group leader. */
|
||||
if (t->getpgid () != myself->pid ||
|
||||
if (!t->getpgid () || t->getpgid () != myself->pid ||
|
||||
(GetTickCount () - t->last_ctrl_c) < MIN_CTRL_C_SLOP)
|
||||
return TRUE;
|
||||
else
|
||||
|
|
|
@ -57,7 +57,7 @@ fillout_pinfo (pid_t pid, int winpid)
|
|||
}
|
||||
else if (nextpid || p->pid == pid || (winpid && thispid == (DWORD) pid))
|
||||
{
|
||||
ep.ctty = tty_attached (p) ? p->ctty : -1;
|
||||
ep.ctty = p->ctty;
|
||||
ep.pid = p->pid;
|
||||
ep.ppid = p->ppid;
|
||||
ep.hProcess = p->hProcess;
|
||||
|
|
|
@ -595,7 +595,6 @@ public:
|
|||
virtual int is_tty () { return 1; }
|
||||
int tcgetpgrp ();
|
||||
int tcsetpgrp (int pid);
|
||||
void set_ctty (int ttynum, int flags);
|
||||
bg_check_types bg_check (int sig);
|
||||
virtual DWORD __acquire_output_mutex (const char *fn, int ln, DWORD ms) {return 1;}
|
||||
virtual void __release_output_mutex (const char *fn, int ln) {}
|
||||
|
|
|
@ -97,10 +97,10 @@ static tty_min NO_COPY *shared_console_info = NULL;
|
|||
|
||||
/* Allocate and initialize the shared record for the current console.
|
||||
Returns a pointer to shared_console_info. */
|
||||
static __inline tty_min *
|
||||
get_tty_stuff (int force = 0)
|
||||
static tty_min *
|
||||
get_tty_stuff (int flags = 0)
|
||||
{
|
||||
if (shared_console_info && !force)
|
||||
if (shared_console_info)
|
||||
return shared_console_info;
|
||||
|
||||
shared_console_info = (tty_min *) open_shared (NULL, cygheap->console_h,
|
||||
|
@ -109,9 +109,16 @@ get_tty_stuff (int force = 0)
|
|||
ProtectHandle (cygheap->console_h);
|
||||
shared_console_info->setntty (TTY_CONSOLE);
|
||||
shared_console_info->setsid (myself->sid);
|
||||
shared_console_info->set_ctty (TTY_CONSOLE, flags);
|
||||
return shared_console_info;
|
||||
}
|
||||
|
||||
void
|
||||
set_console_ctty ()
|
||||
{
|
||||
(void) get_tty_stuff ();
|
||||
}
|
||||
|
||||
/* Return the tty structure associated with a given tty number. If the
|
||||
tty number is < 0, just return a dummy record. */
|
||||
tty_min *
|
||||
|
@ -517,7 +524,7 @@ fhandler_console::open (const char *, int flags, mode_t)
|
|||
{
|
||||
HANDLE h;
|
||||
|
||||
tcinit (get_tty_stuff ());
|
||||
tcinit (get_tty_stuff (flags));
|
||||
|
||||
set_io_handle (INVALID_HANDLE_VALUE);
|
||||
set_output_handle (INVALID_HANDLE_VALUE);
|
||||
|
@ -561,7 +568,6 @@ fhandler_console::open (const char *, int flags, mode_t)
|
|||
}
|
||||
|
||||
TTYCLEARF (RSTCONS);
|
||||
set_ctty (TTY_CONSOLE, flags);
|
||||
set_open_status ();
|
||||
debug_printf ("opened conin$ %p, conout$ %p",
|
||||
get_io_handle (), get_output_handle ());
|
||||
|
|
|
@ -82,28 +82,28 @@ fhandler_termios::tcgetpgrp ()
|
|||
}
|
||||
|
||||
void
|
||||
fhandler_termios::set_ctty (int ttynum, int flags)
|
||||
tty_min::set_ctty (int ttynum, int flags)
|
||||
{
|
||||
if ((myself->ctty < 0 || myself->ctty == ttynum) && !(flags & O_NOCTTY))
|
||||
{
|
||||
myself->ctty = ttynum;
|
||||
syscall_printf ("attached tty%d sid %d, pid %d, tty->pgid %d, tty->sid %d",
|
||||
ttynum, myself->sid, myself->pid, tc->pgid, tc->getsid ());
|
||||
ttynum, myself->sid, myself->pid, pgid, getsid ());
|
||||
|
||||
pinfo p (tc->getsid ());
|
||||
pinfo p (getsid ());
|
||||
if (myself->sid == myself->pid &&
|
||||
(p == myself || !proc_exists (p)))
|
||||
{
|
||||
paranoid_printf ("resetting tty%d sid. Was %d, now %d. pgid was %d, now %d.",
|
||||
ttynum, tc->getsid(), myself->sid, tc->getpgid (), myself->pgid);
|
||||
ttynum, getsid(), myself->sid, getpgid (), myself->pgid);
|
||||
/* We are the session leader */
|
||||
tc->setsid (myself->sid);
|
||||
tc->setpgid (myself->pgid);
|
||||
setsid (myself->sid);
|
||||
setpgid (myself->pgid);
|
||||
}
|
||||
else
|
||||
myself->sid = tc->getsid ();
|
||||
if (tc->getpgid () == 0)
|
||||
tc->setpgid (myself->pgid);
|
||||
myself->sid = getsid ();
|
||||
if (getpgid () == 0)
|
||||
setpgid (myself->pgid);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,9 +220,9 @@ fhandler_termios::line_edit (const char *rptr, int nread, int always_accept)
|
|||
{
|
||||
if (c == tc->ti.c_cc[VSTOP])
|
||||
{
|
||||
if (!tc->OutputStopped)
|
||||
if (!tc->output_stopped)
|
||||
{
|
||||
tc->OutputStopped = 1;
|
||||
tc->output_stopped = 1;
|
||||
acquire_output_mutex (INFINITE);
|
||||
}
|
||||
continue;
|
||||
|
@ -230,11 +230,11 @@ fhandler_termios::line_edit (const char *rptr, int nread, int always_accept)
|
|||
else if (c == tc->ti.c_cc[VSTART])
|
||||
{
|
||||
restart_output:
|
||||
tc->OutputStopped = 0;
|
||||
tc->output_stopped = 0;
|
||||
release_output_mutex ();
|
||||
continue;
|
||||
}
|
||||
else if ((tc->ti.c_iflag & IXANY) && tc->OutputStopped)
|
||||
else if ((tc->ti.c_iflag & IXANY) && tc->output_stopped)
|
||||
goto restart_output;
|
||||
}
|
||||
if (tc->ti.c_lflag & IEXTEN && c == tc->ti.c_cc[VDISCARD])
|
||||
|
|
|
@ -254,7 +254,7 @@ fhandler_pty_master::process_slave_output (char *buf, size_t len, int pktmode_on
|
|||
{
|
||||
/* We need to return a left over \n character, resulting from
|
||||
\r\n conversion. Note that we already checked for FLUSHO and
|
||||
OutputStopped at the time that we read the character, so we
|
||||
output_stopped at the time that we read the character, so we
|
||||
don't check again here. */
|
||||
buf[0] = '\n';
|
||||
need_nl = 0;
|
||||
|
@ -464,7 +464,7 @@ fhandler_tty_slave::open (const char *, int flags, mode_t)
|
|||
tcinit (cygwin_shared->tty[ttynum]);
|
||||
|
||||
attach_tty (ttynum);
|
||||
set_ctty (ttynum, flags);
|
||||
tc->set_ctty (ttynum, flags);
|
||||
|
||||
set_flags (flags);
|
||||
/* Create synchronisation events */
|
||||
|
|
|
@ -67,7 +67,7 @@ typedef enum
|
|||
CW_GET_CYGDRIVE_INFO
|
||||
} cygwin_getinfo_types;
|
||||
|
||||
#define CW_NEXTPID 0x80000000 // or with pid to get next one
|
||||
#define CW_NEXTPID 0x80000000 // or with pid to get next one
|
||||
|
||||
/* Flags associated with process_state */
|
||||
enum
|
||||
|
@ -208,6 +208,8 @@ extern int cygwin_attach_handle_to_fd (char *, int, HANDLE, mode_t, DWORD);
|
|||
|
||||
#include <sys/resource.h>
|
||||
|
||||
#define TTY_CONSOLE 0x40000000
|
||||
|
||||
struct external_pinfo
|
||||
{
|
||||
pid_t pid;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1544,7 +1544,7 @@ ctermid (char *str)
|
|||
static NO_COPY char buf[16];
|
||||
if (str == NULL)
|
||||
str = buf;
|
||||
if (!tty_attached (myself))
|
||||
if (!real_tty_attached (myself))
|
||||
strcpy (str, "/dev/conin");
|
||||
else
|
||||
__small_sprintf (str, "/dev/tty%d", myself->ctty);
|
||||
|
|
|
@ -317,7 +317,7 @@ tty::create_inuse (const char *fmt, BOOL inherit)
|
|||
void
|
||||
tty::init (void)
|
||||
{
|
||||
OutputStopped = 0;
|
||||
output_stopped = 0;
|
||||
setsid (0);
|
||||
pgid = 0;
|
||||
hwnd = NULL;
|
||||
|
|
|
@ -14,8 +14,7 @@ details. */
|
|||
#define INP_BUFFER_SIZE 256
|
||||
#define OUT_BUFFER_SIZE 256
|
||||
#define NTTYS 128
|
||||
#define TTY_CONSOLE 0x40000000
|
||||
#define tty_attached(p) ((p)->ctty >= 0 && (p)->ctty != TTY_CONSOLE)
|
||||
#define real_tty_attached(p) ((p)->ctty >= 0 && (p)->ctty != TTY_CONSOLE)
|
||||
|
||||
/* Input/Output/ioctl events */
|
||||
|
||||
|
@ -52,7 +51,7 @@ class tty_min
|
|||
public:
|
||||
DWORD status;
|
||||
pid_t pgid;
|
||||
int OutputStopped;
|
||||
int output_stopped;
|
||||
int ntty;
|
||||
DWORD last_ctrl_c; // tick count of last ctrl-c
|
||||
|
||||
|
@ -62,6 +61,7 @@ public:
|
|||
void setpgid (int pid) {pgid = pid;}
|
||||
int getsid () {return sid;}
|
||||
void setsid (pid_t tsid) {sid = tsid;}
|
||||
void set_ctty (int ttynum, int flags);
|
||||
struct termios ti;
|
||||
struct winsize winsize;
|
||||
|
||||
|
|
Loading…
Reference in New Issue