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:
Diffstat (limited to 'winsup/cygwin/fhandler_termios.cc')
-rw-r--r--winsup/cygwin/fhandler_termios.cc67
1 files changed, 46 insertions, 21 deletions
diff --git a/winsup/cygwin/fhandler_termios.cc b/winsup/cygwin/fhandler_termios.cc
index 4a8c23862..c1cca494c 100644
--- a/winsup/cygwin/fhandler_termios.cc
+++ b/winsup/cygwin/fhandler_termios.cc
@@ -1,6 +1,6 @@
/* fhandler_termios.cc
- Copyright 1999, 2000, 2001 Red Hat, Inc.
+ Copyright 1999, 2000, 2001, 2002 Red Hat, Inc.
This file is part of Cygwin.
@@ -9,15 +9,14 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
+#include <sys/termios.h>
#include <stdlib.h>
-#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <ctype.h>
#include "cygerrno.h"
#include "security.h"
#include "fhandler.h"
-#include "sync.h"
#include "sigproc.h"
#include "pinfo.h"
#include "tty.h"
@@ -83,6 +82,25 @@ fhandler_termios::tcgetpgrp ()
}
void
+tty_min::kill_pgrp (int sig)
+{
+ int killself = 0;
+ winpids pids;
+ for (unsigned i = 0; i < pids.npids; i++)
+ {
+ _pinfo *p = pids[i];
+ if (!proc_exists (p) || p->ctty != ntty || p->pgid != pgid)
+ continue;
+ if (p == myself)
+ killself++;
+ else
+ (void) sig_send (p, sig);
+ }
+ if (killself)
+ sig_send (myself, sig);
+}
+
+void
tty_min::set_ctty (int ttynum, int flags)
{
if ((myself->ctty < 0 || myself->ctty == ttynum) && !(flags & O_NOCTTY))
@@ -96,7 +114,7 @@ tty_min::set_ctty (int ttynum, int flags)
(p == myself || !proc_exists (p)))
{
paranoid_printf ("resetting tty%d sid. Was %d, now %d. pgid was %d, now %d.",
- ttynum, getsid(), myself->sid, getpgid (), myself->pgid);
+ ttynum, getsid (), myself->sid, getpgid (), myself->pgid);
/* We are the session leader */
setsid (myself->sid);
setpgid (myself->pgid);
@@ -119,7 +137,7 @@ fhandler_termios::bg_check (int sig)
if (sig < 0)
sig = -sig;
- termios_printf("bg I/O pgid %d, tpgid %d, ctty %d",
+ termios_printf ("bg I/O pgid %d, tpgid %d, ctty %d",
myself->pgid, tc->getpgid (), myself->ctty);
if (tc->getsid () == 0)
@@ -136,7 +154,7 @@ fhandler_termios::bg_check (int sig)
return with error */
int pgid_gone = !pid_exists (myself->pgid);
int sigs_ignored =
- ((void *) myself->getsig(sig).sa_handler == (void *) SIG_IGN) ||
+ ((void *) myself->getsig (sig).sa_handler == (void *) SIG_IGN) ||
(myself->getsigmask () & SIGTOMASK (sig));
if (pgid_gone)
@@ -151,7 +169,7 @@ fhandler_termios::bg_check (int sig)
/* Don't raise a SIGTT* signal if we have already been interrupted
by another signal. */
if (WaitForSingleObject (signal_arrived, 0) != WAIT_OBJECT_0)
- _raise (sig);
+ kill_pgrp (myself->pgid, sig);
return bg_signalled;
setEIO:
@@ -207,18 +225,18 @@ fhandler_termios::line_edit (const char *rptr, int nread, int always_accept)
if (tc->ti.c_lflag & ISIG)
{
int sig;
- if (c == tc->ti.c_cc[VINTR])
+ if (CCEQ(tc->ti.c_cc[VINTR], c))
sig = SIGINT;
- else if (c == tc->ti.c_cc[VQUIT])
+ else if (CCEQ(tc->ti.c_cc[VQUIT], c))
sig = SIGQUIT;
- else if (c == tc->ti.c_cc[VSUSP])
+ else if (CCEQ(tc->ti.c_cc[VSUSP], c))
sig = SIGTSTP;
else
goto not_a_sig;
termios_printf ("got interrupt %d, sending signal %d", c, sig);
eat_readahead (-1);
- kill_pgrp (tc->getpgid (), sig);
+ tc->kill_pgrp (sig);
tc->ti.c_lflag &= ~FLUSHO;
sawsig = 1;
goto restart_output;
@@ -226,7 +244,7 @@ fhandler_termios::line_edit (const char *rptr, int nread, int always_accept)
not_a_sig:
if (tc->ti.c_iflag & IXON)
{
- if (c == tc->ti.c_cc[VSTOP])
+ if (CCEQ(tc->ti.c_cc[VSTOP], c))
{
if (!tc->output_stopped)
{
@@ -235,7 +253,7 @@ fhandler_termios::line_edit (const char *rptr, int nread, int always_accept)
}
continue;
}
- else if (c == tc->ti.c_cc[VSTART])
+ else if (CCEQ(tc->ti.c_cc[VSTART], c))
{
restart_output:
tc->output_stopped = 0;
@@ -245,20 +263,20 @@ fhandler_termios::line_edit (const char *rptr, int nread, int always_accept)
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])
+ if (iscanon && tc->ti.c_lflag & IEXTEN && CCEQ(tc->ti.c_cc[VDISCARD], c))
{
tc->ti.c_lflag ^= FLUSHO;
continue;
}
if (!iscanon)
/* nothing */;
- else if (c == tc->ti.c_cc[VERASE])
+ else if (CCEQ(tc->ti.c_cc[VERASE], c))
{
if (eat_readahead (1))
echo_erase ();
continue;
}
- else if (c == tc->ti.c_cc[VWERASE])
+ else if (CCEQ(tc->ti.c_cc[VWERASE], c))
{
int ch;
do
@@ -269,7 +287,7 @@ fhandler_termios::line_edit (const char *rptr, int nread, int always_accept)
while ((ch = peek_readahead (1)) >= 0 && !isspace (ch));
continue;
}
- else if (c == tc->ti.c_cc[VKILL])
+ else if (CCEQ(tc->ti.c_cc[VKILL], c))
{
int nchars = eat_readahead (-1);
if (tc->ti.c_lflag & ECHO)
@@ -277,7 +295,7 @@ fhandler_termios::line_edit (const char *rptr, int nread, int always_accept)
echo_erase (1);
continue;
}
- else if (c == tc->ti.c_cc[VREPRINT])
+ else if (CCEQ(tc->ti.c_cc[VREPRINT], c))
{
if (tc->ti.c_lflag & ECHO)
{
@@ -286,14 +304,14 @@ fhandler_termios::line_edit (const char *rptr, int nread, int always_accept)
}
continue;
}
- else if (c == tc->ti.c_cc[VEOF])
+ else if (CCEQ(tc->ti.c_cc[VEOF], c))
{
termios_printf ("EOF");
input_done = 1;
continue;
}
- else if (c == tc->ti.c_cc[VEOL] ||
- c == tc->ti.c_cc[VEOL2] ||
+ else if (CCEQ(tc->ti.c_cc[VEOL], c) ||
+ CCEQ(tc->ti.c_cc[VEOL2], c) ||
c == '\n')
{
set_input_done (1);
@@ -325,3 +343,10 @@ fhandler_termios::fixup_after_fork (HANDLE parent)
this->fhandler_base::fixup_after_fork (parent);
fork_fixup (parent, get_output_handle (), "output_handle");
}
+
+__off64_t
+fhandler_termios::lseek (__off64_t, int)
+{
+ set_errno (ESPIPE);
+ return -1;
+}