]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
terminal-util: correct fd validity check
authorMike Yuan <me@yhndnzj.com>
Sat, 7 Sep 2024 19:27:20 +0000 (21:27 +0200)
committerMike Yuan <me@yhndnzj.com>
Sun, 8 Sep 2024 18:45:33 +0000 (20:45 +0200)
Follow-up for 14f594b995bbaea85456a4c26e5c07446a4c446e

src/basic/terminal-util.c

index a97312c9bf4117f840b96dbdbb520fd6c4f9168b..94720c9adf242d9d8f865559e834a01a41eb83a0 100644 (file)
@@ -146,7 +146,7 @@ int read_one_char(FILE *f, char *ret, usec_t t, bool *need_nl) {
                 }
         }
 
-        if (t != USEC_INFINITY && fd > 0) {
+        if (t != USEC_INFINITY && fd >= 0) {
                 /* Let's wait the specified amount of time for input. When we have no fd we skip this, under
                  * the assumption that this is an fmemopen() stream or so where waiting doesn't make sense
                  * anyway, as the data is either already in the stream or cannot possible be placed there