aboutsummaryrefslogtreecommitdiffstats
path: root/sircbot.c
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2010-06-29 12:52:48 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2010-06-29 12:52:48 +0000
commit289edb6f7d261d4dcc34fcf0b85b6cb2a1e94f62 (patch)
treeacda189c457bb40dca2943fda9638115cbad686c /sircbot.c
parent233f685e2a2a5033b077e9945c4b6f21fe7c5046 (diff)
downloadsircbot-289edb6f7d261d4dcc34fcf0b85b6cb2a1e94f62.tar.bz2
sircbot-289edb6f7d261d4dcc34fcf0b85b6cb2a1e94f62.tar.xz
handle POLLHUP from fifos
when process that writes to fifo exits, the fifo is closed. We handle this by just re-opening it.
Diffstat (limited to 'sircbot.c')
-rw-r--r--sircbot.c17
1 files changed, 14 insertions, 3 deletions
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;