From 9a737ab7a40984cfdfffd014562a220a3736a10f Mon Sep 17 00:00:00 2001 From: Austin Foxley Date: Sat, 17 Oct 2009 14:25:01 -0700 Subject: use *_not_cancel variants to avoid accidental cancellations with nptl Signed-off-by: Austin Foxley --- libc/misc/dirent/opendir.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'libc/misc/dirent/opendir.c') diff --git a/libc/misc/dirent/opendir.c b/libc/misc/dirent/opendir.c index b43f60814..4a23ab061 100644 --- a/libc/misc/dirent/opendir.c +++ b/libc/misc/dirent/opendir.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "dirstream.h" @@ -81,7 +82,7 @@ DIR *opendir(const char *name) } # define O_DIRECTORY 0 #endif - fd = open(name, O_RDONLY|O_NDELAY|O_DIRECTORY|O_CLOEXEC); + fd = open_not_cancel_2(name, O_RDONLY|O_NDELAY|O_DIRECTORY|O_CLOEXEC); if (fd < 0) return NULL; /* Note: we should check to make sure that between the stat() and open() @@ -93,7 +94,7 @@ DIR *opendir(const char *name) /* this close() never fails *int saved_errno; *saved_errno = errno; */ - close(fd); + close_not_cancel_no_status(fd); /*__set_errno(saved_errno);*/ return NULL; } @@ -102,12 +103,13 @@ DIR *opendir(const char *name) * exec. From "Anna Pluzhnikov" . */ #ifndef __ASSUME_O_CLOEXEC - fcntl(fd, F_SETFD, FD_CLOEXEC); + fcntl_not_cancel(fd, F_SETFD, FD_CLOEXEC); #endif ptr = fd_to_DIR(fd, statbuf.st_blksize); + if (!ptr) { - close(fd); + close_not_cancel_no_status(fd); __set_errno(ENOMEM); } return ptr; -- cgit v1.2.3