X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Funlockpt.c;h=a449311f33915719e5e3da6f7406fe2e5bf88e1e;hb=e1c466d11a91615c413789ea8bc3ec358f2c6aa9;hp=f2becab23753394f520b7e2e9a3d442c2c4cb6a5;hpb=e6c527d59af1fd07e33830f72c8c93e31cfd3738;p=gnulib.git diff --git a/lib/unlockpt.c b/lib/unlockpt.c index f2becab23..a449311f3 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-2014 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 }