Cygwin: pty: Make FLUSHO and Ctrl-O work.
- Previously, FLUSHO feature was implemented incompletely. With this patch, FLUSHO and Ctrl-O (VDISCARD) get working.
This commit is contained in:
parent
1c70319bda
commit
9677efcf00
|
@ -2467,6 +2467,7 @@ public:
|
||||||
bool to_be_read_from_pcon (void);
|
bool to_be_read_from_pcon (void);
|
||||||
void get_master_thread_param (master_thread_param_t *p);
|
void get_master_thread_param (master_thread_param_t *p);
|
||||||
void get_master_fwd_thread_param (master_fwd_thread_param_t *p);
|
void get_master_fwd_thread_param (master_fwd_thread_param_t *p);
|
||||||
|
void set_mask_flusho (bool m) { get_ttyp ()->mask_flusho = m; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class fhandler_dev_null: public fhandler_base
|
class fhandler_dev_null: public fhandler_base
|
||||||
|
|
|
@ -612,8 +612,8 @@ fhandler_pty_master::process_slave_output (char *buf, size_t len, int pktmode_on
|
||||||
rc = -1;
|
rc = -1;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
/* DISCARD (FLUSHO) and tcflush can finish here. */
|
/* tclush can finish here. */
|
||||||
if ((get_ttyp ()->ti.c_lflag & FLUSHO || !buf))
|
if (!buf)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (is_nonblocking ())
|
if (is_nonblocking ())
|
||||||
|
@ -671,8 +671,9 @@ fhandler_pty_master::process_slave_output (char *buf, size_t len, int pktmode_on
|
||||||
|
|
||||||
termios_printf ("bytes read %u", n);
|
termios_printf ("bytes read %u", n);
|
||||||
|
|
||||||
if (get_ttyp ()->ti.c_lflag & FLUSHO || !buf)
|
if (!buf || ((get_ttyp ()->ti.c_lflag & FLUSHO)
|
||||||
continue;
|
&& !get_ttyp ()->mask_flusho))
|
||||||
|
continue; /* Discard read data */
|
||||||
|
|
||||||
memcpy (optr, outbuf, n);
|
memcpy (optr, outbuf, n);
|
||||||
optr += n;
|
optr += n;
|
||||||
|
@ -691,6 +692,8 @@ fhandler_pty_master::process_slave_output (char *buf, size_t len, int pktmode_on
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
if (buf)
|
||||||
|
set_mask_flusho (false);
|
||||||
termios_printf ("returning %d", rc);
|
termios_printf ("returning %d", rc);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -2036,7 +2039,7 @@ fhandler_pty_master::write (const void *ptr, size_t len)
|
||||||
{
|
{
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
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)
|
||||||
|
@ -2193,7 +2196,7 @@ fhandler_pty_master::tcflush (int queue)
|
||||||
|
|
||||||
if (queue == TCIFLUSH || queue == TCIOFLUSH)
|
if (queue == TCIFLUSH || queue == TCIOFLUSH)
|
||||||
ret = process_slave_output (NULL, OUT_BUFFER_SIZE, 0);
|
ret = process_slave_output (NULL, OUT_BUFFER_SIZE, 0);
|
||||||
else if (queue == TCIFLUSH || queue == TCIOFLUSH)
|
if (queue == TCOFLUSH || queue == TCIOFLUSH)
|
||||||
{
|
{
|
||||||
/* do nothing for now. */
|
/* do nothing for now. */
|
||||||
}
|
}
|
||||||
|
@ -2929,6 +2932,8 @@ fhandler_pty_common::process_opost_output (HANDLE h, const void *ptr,
|
||||||
{
|
{
|
||||||
ssize_t towrite = len;
|
ssize_t towrite = len;
|
||||||
BOOL res = TRUE;
|
BOOL res = TRUE;
|
||||||
|
if (ttyp->ti.c_lflag & FLUSHO)
|
||||||
|
return res; /* Discard write data */
|
||||||
while (towrite)
|
while (towrite)
|
||||||
{
|
{
|
||||||
if (!is_echo)
|
if (!is_echo)
|
||||||
|
|
|
@ -710,6 +710,11 @@ peek_pipe (select_record *s, bool from_select)
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
if (fh->get_major () == DEV_PTYM_MAJOR)
|
||||||
|
{
|
||||||
|
fhandler_pty_master *fhm = (fhandler_pty_master *) fh;
|
||||||
|
fhm->set_mask_flusho (s->read_ready);
|
||||||
|
}
|
||||||
h = fh->get_output_handle_cyg ();
|
h = fh->get_output_handle_cyg ();
|
||||||
if (s->write_selected && dev != FH_PIPER)
|
if (s->write_selected && dev != FH_PIPER)
|
||||||
{
|
{
|
||||||
|
|
|
@ -252,6 +252,7 @@ tty::init ()
|
||||||
req_xfer_input = false;
|
req_xfer_input = false;
|
||||||
pcon_input_state = to_cyg;
|
pcon_input_state = to_cyg;
|
||||||
last_sig = 0;
|
last_sig = 0;
|
||||||
|
mask_flusho = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE
|
HANDLE
|
||||||
|
|
|
@ -130,6 +130,7 @@ private:
|
||||||
bool master_is_running_as_service;
|
bool master_is_running_as_service;
|
||||||
bool req_xfer_input;
|
bool req_xfer_input;
|
||||||
xfer_dir pcon_input_state;
|
xfer_dir pcon_input_state;
|
||||||
|
bool mask_flusho;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HANDLE from_master () const { return _from_master; }
|
HANDLE from_master () const { return _from_master; }
|
||||||
|
|
Loading…
Reference in New Issue