From 289edb6f7d261d4dcc34fcf0b85b6cb2a1e94f62 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Tue, 29 Jun 2010 12:52:48 +0000 Subject: handle POLLHUP from fifos when process that writes to fifo exits, the fifo is closed. We handle this by just re-opening it. --- sircbot.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'sircbot.c') diff --git a/sircbot.c b/sircbot.c index 30f870f..67dc5a9 100644 --- a/sircbot.c +++ b/sircbot.c @@ -348,9 +348,20 @@ static int irc_loop(struct irc_session *sess, struct sircbot_channel *chan, send_fifo_queue(sess, &chan[i-1], now) < 0) goto ret_err; - if ((fds[i].revents & POLLHUP) && i == 0) - /* server hang up on us */ - return 0; + if (fds[i].revents & POLLHUP) { + if (i == 0) + /* server hang up on us */ + return 0; + + /* one of the fifos closed due to + writer process exit. We just + reopen it assuming we are still + joined the channel */ + close_fifo(&chan[i-1], + chan[i-1].last_closetime); + init_fifo(&chan[i-1]); + continue; + } if (fds[i].revents & POLLERR) goto ret_err; -- cgit v1.2.3