diff options
-rw-r--r-- | src/main.c | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -369,9 +369,19 @@ int main (int argc, char **argv) { assert (sizeof (app.input.fds) / sizeof (*app.input.fds) >= 2); app.input.fds[1] = open (app.settings.fifo, O_RDWR); if (app.input.fds[1] != -1) { - FD_SET(app.input.fds[1], &app.input.set); - BarUiMsg (&app.settings, MSG_INFO, "Control fifo at %s opened\n", - app.settings.fifo); + struct stat s; + + /* check for file type, must be fifo */ + fstat (app.input.fds[1], &s); + if (!S_ISFIFO (s.st_mode)) { + BarUiMsg (&app.settings, MSG_ERR, "File at %s is not a fifo\n", app.settings.fifo); + close (app.input.fds[1]); + app.input.fds[1] = -1; + } else { + FD_SET(app.input.fds[1], &app.input.set); + BarUiMsg (&app.settings, MSG_INFO, "Control fifo at %s opened\n", + app.settings.fifo); + } } app.input.maxfd = app.input.fds[0] > app.input.fds[1] ? app.input.fds[0] : app.input.fds[1]; |