use 0 instead of NULL for null pointer constants
[musl] / src / misc / nftw.c
index 1b94ac1..b2e84bc 100644 (file)
@@ -2,11 +2,10 @@
 #include <dirent.h>
 #include <sys/stat.h>
 #include <errno.h>
-#include <stdlib.h>
-#include <fcntl.h>
 #include <unistd.h>
 #include <string.h>
 #include <limits.h>
+#include <pthread.h>
 #include "libc.h"
 
 struct history
@@ -103,6 +102,7 @@ static int do_nftw(char *path, int (*fn)(const char *, const struct stat *, int,
 
 int nftw(const char *path, int (*fn)(const char *, const struct stat *, int, struct FTW *), int fd_limit, int flags)
 {
+       int r, cs;
        size_t l;
        char pathbuf[PATH_MAX+1];
 
@@ -115,7 +115,10 @@ int nftw(const char *path, int (*fn)(const char *, const struct stat *, int, str
        }
        memcpy(pathbuf, path, l+1);
        
-       return do_nftw(pathbuf, fn, fd_limit, flags, NULL);
+       pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
+       r = do_nftw(pathbuf, fn, fd_limit, flags, NULL);
+       pthread_setcancelstate(cs, 0);
+       return r;
 }
 
 LFS64(nftw);