Loading...
threads/cprocs.c Libc-391 Libc-825.26
--- Libc/Libc-391/threads/cprocs.c
+++ Libc/Libc-825.26/threads/cprocs.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999, 2008 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
@@ -137,20 +137,27 @@
 #undef errno
 extern int errno;
 extern int *__error(void);
+extern int __pthread_canceled(int);
 
 void
-cthread_set_errno_self(error)
-	int	error;
+cthread_set_errno_self(int error, int nocancel)
 {
 	int *ep = __error();
 	extern int __unix_conforming;
+	pthread_t self = NULL;
+	int check_cancel = __unix_conforming && !nocancel;
 
-	if ((__unix_conforming) && (error == EINTR) && (__pthread_canceled(0) == 0))
+	if (check_cancel && ((error & 0xff) == EINTR) && (__pthread_canceled(0) == 0)) {
+		self = pthread_self();
+		if (self != NULL)
+			self->cancel_error = error;
 		pthread_exit(PTHREAD_CANCELED);
+	}
 
-        if (ep != &errno)
-            *ep = error;
+	if (ep != &errno) {
+		*ep = error;
+	}
 
-        errno = error;
+	errno = error;
 }