From: David Goulet Date: Wed, 7 Sep 2011 19:50:08 +0000 (-0400) Subject: Add a safety check to nbfd of apps cmd pollfd X-Git-Tag: v2.0-pre13~13 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=733bb3da0f1ef5005ffe5df7811875e737cb3414;p=lttng-tools.git Add a safety check to nbfd of apps cmd pollfd Signed-off-by: David Goulet --- diff --git a/ltt-sessiond/main.c b/ltt-sessiond/main.c index c9522d697..436ee9f16 100644 --- a/ltt-sessiond/main.c +++ b/ltt-sessiond/main.c @@ -880,6 +880,15 @@ static int update_apps_cmd_pollfd(unsigned int nb_fd, unsigned int old_nb_fd, } } + if (nb_fd < 2) { + /* + * There should *always* be at least two fds in the pollfd. This safety + * check make sure the poll() will actually try on those two pipes at + * best which are the thread_quit_pipe and apps_cmd_pipe. + */ + nb_fd = 2; + } + /* Destroy old pollfd */ free(old_pollfd);