X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=util.c;h=f8b3f44ad15d665aa4a25a48cf44fb62f087a665;hp=8042214c8fae7fdd40494691d216624a26cfeee8;hb=d9a76d8f860c4ee19c4aa0df685889d058f4c5cb;hpb=3177a7fa12247d30b854fcb7697cd578b9086bf5 diff --git a/util.c b/util.c index 8042214c8..f8b3f44ad 100644 --- a/util.c +++ b/util.c @@ -1597,7 +1597,7 @@ int flush_fd(int fd) { } int acquire_terminal(const char *name, bool fail, bool force) { - int fd = -1, notify = -1, r, wd; + int fd = -1, notify = -1, r, wd = -1; assert(name); @@ -1627,8 +1627,9 @@ int acquire_terminal(const char *name, bool fail, bool force) { } for (;;) { - if ((r = flush_fd(notify)) < 0) - goto fail; + if (notify >= 0) + if ((r = flush_fd(notify)) < 0) + goto fail; /* We pass here O_NOCTTY only so that we can check the return * value TIOCSCTTY and have a reliable way to figure out if we