Merge commit 'b572c3a256e7bf1e4eecc8c36448c08093240a6a' into stable
[gnulib.git] / lib / unlockpt.c
index e03b31f..6785487 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <stdlib.h>
 
+#include <fcntl.h>
 #include <unistd.h>
 
 int
@@ -36,6 +37,8 @@ unlockpt (int fd)
 #else
   /* Assume that the slave side of a pseudo-terminal is already unlocked
      by default.  */
+  if (fcntl (fd, F_GETFD) < 0)
+    return -1;
   return 0;
 #endif
 }