From 53aee7dc387743d37db93cb0c88d368204dadcc6 Mon Sep 17 00:00:00 2001 From: Kevin Lange Date: Thu, 29 May 2014 21:39:56 -0700 Subject: [PATCH] Implement ^D --- kernel/fs/tty.c | 12 ++++++++++++ kernel/fs/unixpipe.c | 3 +++ 2 files changed, 15 insertions(+) diff --git a/kernel/fs/tty.c b/kernel/fs/tty.c index 0e8bef49..3674bc33 100644 --- a/kernel/fs/tty.c +++ b/kernel/fs/tty.c @@ -116,6 +116,16 @@ static void input_process(pty_t * pty, uint8_t c) { } return; } + if (c == pty->tios.c_cc[VEOF]) { + if (pty->tios.c_lflag & ECHO) { + output_process(pty, '^'); + output_process(pty, '@' + c); + output_process(pty, '\n'); + } + clear_input_buffer(pty); + ring_buffer_interrupt(pty->in); + return; + } pty->canon_buffer[pty->canon_buflen] = c; if (pty->tios.c_lflag & ECHO) { output_process(pty, c); @@ -123,10 +133,12 @@ static void input_process(pty_t * pty, uint8_t c) { if (pty->canon_buffer[pty->canon_buflen] == '\n') { pty->canon_buflen++; dump_input_buffer(pty); + ring_buffer_interrupt(pty->in); return; } if (pty->canon_buflen == pty->canon_bufsize) { dump_input_buffer(pty); + ring_buffer_interrupt(pty->in); return; } pty->canon_buflen++; diff --git a/kernel/fs/unixpipe.c b/kernel/fs/unixpipe.c index bdb80ea5..81ee97b3 100644 --- a/kernel/fs/unixpipe.c +++ b/kernel/fs/unixpipe.c @@ -32,6 +32,9 @@ static uint32_t read_unixpipe(fs_node_t * node, uint32_t offset, uint32_t size, return read; } size_t r = ring_buffer_read(self->buffer, 1, buffer+read); + if (r && *((char *)(buffer + read)) == '\n') { + return read+r; + } read += r; }