X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Funlockpt.c;h=6c056f9245c32d55d2a00dfa87ba461e4bdaca24;hb=f62a2da1390a78aebe7dcbc5753ba7a2b34cf1fd;hp=f2becab23753394f520b7e2e9a3d442c2c4cb6a5;hpb=e6c527d59af1fd07e33830f72c8c93e31cfd3738;p=gnulib.git diff --git a/lib/unlockpt.c b/lib/unlockpt.c index f2becab23..6c056f924 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 Free Software Foundation, Inc. + Copyright (C) 1998, 2010-2012 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 }