X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Funlockpt.c;h=face05cfc5e7487c70e3e5bc5f474a0e7a1077e0;hb=43593319b31e6b0175b8eec4433bac744959822d;hp=e03b31f35430f58ce096bb4c61d021a011748a81;hpb=d60f3b0c6b0f93a601acd1cfd3923f94ca05abb0;p=gnulib.git diff --git a/lib/unlockpt.c b/lib/unlockpt.c index e03b31f35..face05cfc 100644 --- a/lib/unlockpt.c +++ b/lib/unlockpt.c @@ -1,5 +1,5 @@ /* Unlock the slave side of a pseudo-terminal from its master side. - Copyright (C) 1998, 2010-2011 Free Software Foundation, Inc. + Copyright (C) 1998, 2010-2013 Free Software Foundation, Inc. Contributed by Zack Weinberg , 1998. This program is free software: you can redistribute it and/or modify @@ -19,6 +19,7 @@ #include +#include #include int @@ -27,7 +28,7 @@ unlockpt (int fd) /* Platforms which have the TIOCSPTLCK ioctl (Linux) already have the unlockpt function. */ #if HAVE_REVOKE - /* MacOS X 10.3, OpenBSD 3.8 do not have the unlockpt function, but they + /* Mac OS X 10.3, OpenBSD 3.8 do not have the unlockpt function, but they have revoke(). */ char *name = ptsname (fd); if (name == NULL) @@ -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 }