From db4b25d8b2edbafa898b9ca12b8900bda5c0be1e Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 15 Sep 2005 23:50:05 +0000 Subject: handle EOF in ioline.c git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@348 fefdeb5f-60dc-0310-8127-8f9354f1896f --- polyp/ioline.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'polyp') diff --git a/polyp/ioline.c b/polyp/ioline.c index 6f7886da..f437094d 100644 --- a/polyp/ioline.c +++ b/polyp/ioline.c @@ -262,8 +262,16 @@ static int do_read(struct pa_ioline *l) { assert(len >= READ_SIZE); /* Read some data */ - if ((r = pa_iochannel_read(l->io, l->rbuf+l->rbuf_index+l->rbuf_valid_length, len)) <= 0) { - pa_log(__FILE__": read() failed: %s\n", r < 0 ? strerror(errno) : "EOF"); + r = pa_iochannel_read(l->io, l->rbuf+l->rbuf_index+l->rbuf_valid_length, len); + if (r == 0) { + /* Got an EOF, so fake an exit command. */ + l->rbuf_index = 0; + snprintf (l->rbuf, l->rbuf_length, "exit\n"); + r = 5; + pa_ioline_puts(l, "\nExiting.\n"); + do_write(l); + } else if (r < 0) { + pa_log(__FILE__": read() failed: %s\n", strerror(errno)); failure(l); return -1; } -- cgit