tty: implement FLUSH on tcsetattr correctly?
This commit is contained in:
parent
2f27cce0cd
commit
938bbf51eb
@ -31,4 +31,5 @@ void ring_buffer_interrupt(ring_buffer_t * ring_buffer);
|
|||||||
void ring_buffer_alert_waiters(ring_buffer_t * ring_buffer);
|
void ring_buffer_alert_waiters(ring_buffer_t * ring_buffer);
|
||||||
void ring_buffer_select_wait(ring_buffer_t * ring_buffer, void * process);
|
void ring_buffer_select_wait(ring_buffer_t * ring_buffer, void * process);
|
||||||
void ring_buffer_eof(ring_buffer_t * ring_buffer);
|
void ring_buffer_eof(ring_buffer_t * ring_buffer);
|
||||||
|
void ring_buffer_discard(ring_buffer_t * ring_buffer);
|
||||||
|
|
||||||
|
@ -86,6 +86,12 @@ void ring_buffer_select_wait(ring_buffer_t * ring_buffer, void * process) {
|
|||||||
list_insert(((process_t *)process)->node_waits, ring_buffer);
|
list_insert(((process_t *)process)->node_waits, ring_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ring_buffer_discard(ring_buffer_t * ring_buffer) {
|
||||||
|
spin_lock(ring_buffer->lock);
|
||||||
|
ring_buffer->read_ptr = ring_buffer->write_ptr;
|
||||||
|
spin_unlock(ring_buffer->lock);
|
||||||
|
}
|
||||||
|
|
||||||
size_t ring_buffer_read(ring_buffer_t * ring_buffer, size_t size, uint8_t * buffer) {
|
size_t ring_buffer_read(ring_buffer_t * ring_buffer, size_t size, uint8_t * buffer) {
|
||||||
size_t collected = 0;
|
size_t collected = 0;
|
||||||
while (collected == 0) {
|
while (collected == 0) {
|
||||||
|
@ -322,13 +322,18 @@ int pty_ioctl(pty_t * pty, unsigned long request, void * argp) {
|
|||||||
return 0;
|
return 0;
|
||||||
case TCSETS:
|
case TCSETS:
|
||||||
case TCSETSW:
|
case TCSETSW:
|
||||||
case TCSETSF:
|
|
||||||
if (!argp) return -EINVAL;
|
if (!argp) return -EINVAL;
|
||||||
validate(argp);
|
validate(argp);
|
||||||
|
/* TODO wait on output for SETSW */
|
||||||
if (!(((struct termios *)argp)->c_lflag & ICANON) && (pty->tios.c_lflag & ICANON)) {
|
if (!(((struct termios *)argp)->c_lflag & ICANON) && (pty->tios.c_lflag & ICANON)) {
|
||||||
/* Switch out of canonical mode, the dump the input buffer */
|
/* Switch out of canonical mode, the dump the input buffer */
|
||||||
dump_input_buffer(pty);
|
dump_input_buffer(pty);
|
||||||
}
|
}
|
||||||
|
goto tcset_common;
|
||||||
|
case TCSETSF:
|
||||||
|
clear_input_buffer(pty);
|
||||||
|
ring_buffer_discard(pty->in);
|
||||||
|
tcset_common:
|
||||||
memcpy(&pty->tios, argp, sizeof(struct termios));
|
memcpy(&pty->tios, argp, sizeof(struct termios));
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user