diff options
author | Lennart Poettering <lennart@poettering.net> | 2005-09-15 23:50:05 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2005-09-15 23:50:05 +0000 |
commit | db4b25d8b2edbafa898b9ca12b8900bda5c0be1e (patch) | |
tree | 443b065cf0cfa3403608e2d2840b5d776c01df3d /polyp | |
parent | fda09b92555bcd9b8e3cbd710557c1b0784cd697 (diff) |
handle EOF in ioline.c
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@348 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'polyp')
-rw-r--r-- | polyp/ioline.c | 12 |
1 files changed, 10 insertions, 2 deletions
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; } |