From d01d634bc7b848ba0ee8e45972ba1bbccb77f3d1 Mon Sep 17 00:00:00 2001 From: KWSys Upstream Date: Sat, 29 Jan 2022 07:04:51 -0500 Subject: KWSys 2022-01-29 (389a74dc) Code extracted from: https://gitlab.kitware.com/utils/kwsys.git at commit 389a74dc7bef2c10d663569bf61c64e25f46b7c7 (master). Upstream Shortlog ----------------- Brad King (1): 259cdb6a SystemTools: Update SetPermissions test case to avoid 0 perms on POSIX Christopher Chavez (1): 5a33629f ProcessUNIX.c: fix select(), FD_SETSIZE on macOS --- ProcessUNIX.c | 6 ++++++ testSystemTools.cxx | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ProcessUNIX.c b/ProcessUNIX.c index 1963b27..19bf982 100644 --- a/ProcessUNIX.c +++ b/ProcessUNIX.c @@ -41,6 +41,12 @@ do. /* Increase the file descriptor limit for select() before including related system headers. (Default: 64) */ # define FD_SETSIZE 16384 +#elif defined(__APPLE__) +/* Increase the file descriptor limit for select() before including + related system headers. (Default: 1024) */ +# define _DARWIN_UNLIMITED_SELECT +# include /* OPEN_MAX */ +# define FD_SETSIZE OPEN_MAX #endif #include /* assert */ diff --git a/testSystemTools.cxx b/testSystemTools.cxx index e88a481..21d6f04 100644 --- a/testSystemTools.cxx +++ b/testSystemTools.cxx @@ -295,12 +295,15 @@ static bool CheckFileOperations() // Reset umask #ifdef __MSYS__ mode_t fullMask = S_IWRITE; + mode_t testPerm = S_IREAD; #elif defined(_WIN32) && !defined(__CYGWIN__) // NOTE: Windows doesn't support toggling _S_IREAD. mode_t fullMask = _S_IWRITE; + mode_t testPerm = 0; #else // On a normal POSIX platform, we can toggle all permissions. mode_t fullMask = S_IRWXU | S_IRWXG | S_IRWXO; + mode_t testPerm = S_IRUSR; #endif // Test file permissions without umask @@ -311,7 +314,7 @@ static bool CheckFileOperations() res = false; } - if (!kwsys::SystemTools::SetPermissions(testNewFile, 0)) { + if (!kwsys::SystemTools::SetPermissions(testNewFile, testPerm)) { std::cerr << "Problem with SetPermissions (1) for: " << testNewFile << std::endl; res = false; @@ -323,10 +326,10 @@ static bool CheckFileOperations() res = false; } - if ((thisPerm & fullMask) != 0) { + if ((thisPerm & fullMask) != testPerm) { std::cerr << "SetPermissions failed to set permissions (1) for: " << testNewFile << ": actual = " << thisPerm - << "; expected = " << 0 << std::endl; + << "; expected = " << testPerm << std::endl; res = false; } -- cgit v0.12