mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-27 00:09:01 +08:00
aaeca7b000
* [physfs] Patches to fix behavior on macOS / Linux * Run x-add-version physfs * Update ports/physfs/portfile.cmake * Update ports/physfs/portfile.cmake * Update versions/p-/physfs.json Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com>
35 lines
916 B
Diff
35 lines
916 B
Diff
diff --git a/src/physfs_platform_posix.c b/src/physfs_platform_posix.c
|
|
--- a/src/physfs_platform_posix.c
|
|
+++ b/src/physfs_platform_posix.c
|
|
@@ -160,16 +160,30 @@ static void *doOpen(const char *filename, int mode)
|
|
const int appending = (mode & O_APPEND);
|
|
int fd;
|
|
int *retval;
|
|
+ int flags;
|
|
+ flags = -1;
|
|
errno = 0;
|
|
|
|
/* O_APPEND doesn't actually behave as we'd like. */
|
|
mode &= ~O_APPEND;
|
|
+
|
|
+#ifdef O_CLOEXEC
|
|
+ /* Add O_CLOEXEC if defined */
|
|
+ mode |= O_CLOEXEC;
|
|
+#endif
|
|
|
|
do {
|
|
fd = open(filename, mode, S_IRUSR | S_IWUSR);
|
|
} while ((fd < 0) && (errno == EINTR));
|
|
BAIL_IF(fd < 0, errcodeFromErrno(), NULL);
|
|
|
|
+#if !defined(O_CLOEXEC) && defined(FD_CLOEXEC)
|
|
+ flags = fcntl(fd, F_GETFD);
|
|
+ if (flags != -1) {
|
|
+ fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
|
|
+ }
|
|
+#endif
|
|
+
|
|
if (appending)
|
|
{
|
|
if (lseek(fd, 0, SEEK_END) < 0)
|