summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index f431331..43f3ffc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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];