Patch #716969: Detect thread creation failure. Will backport to 2.2.
diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h
index 2596af5..2e594fe 100644
--- a/Python/thread_pthread.h
+++ b/Python/thread_pthread.h
@@ -188,7 +188,7 @@
 PyThread_start_new_thread(void (*func)(void *), void *arg)
 {
 	pthread_t th;
-	int success;
+	int status;
  	sigset_t oldmask, newmask;
 #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
 	pthread_attr_t attrs;
@@ -214,7 +214,7 @@
 	sigfillset(&newmask);
 	SET_THREAD_SIGMASK(SIG_BLOCK, &newmask, &oldmask);
 
-	success = pthread_create(&th, 
+	status = pthread_create(&th, 
 #if defined(PY_PTHREAD_D4)
 				 pthread_attr_default,
 				 (pthread_startroutine_t)func, 
@@ -244,13 +244,15 @@
 #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
 	pthread_attr_destroy(&attrs);
 #endif
-	if (success == 0) {
+	if (status != 0)
+            return -1;
+
 #if defined(PY_PTHREAD_D4) || defined(PY_PTHREAD_D6) || defined(PY_PTHREAD_D7)
-		pthread_detach(&th);
+        pthread_detach(&th);
 #elif defined(PY_PTHREAD_STD)
-		pthread_detach(th);
+        pthread_detach(th);
 #endif
-	}
+
 #if SIZEOF_PTHREAD_T <= SIZEOF_LONG
 	return (long) th;
 #else
diff --git a/Python/thread_solaris.h b/Python/thread_solaris.h
index d3512d4..ff3e6f3 100644
--- a/Python/thread_solaris.h
+++ b/Python/thread_solaris.h
@@ -40,8 +40,6 @@
 {
 	thread_t tid;
 	struct func_arg *funcarg;
-	int success = 0;	/* init not needed when SOLARIS_THREADS and */
-				/* C_THREADS implemented properly */
 
 	dprintf(("PyThread_start_new_thread called\n"));
 	if (!initialized)
@@ -53,7 +51,7 @@
 		       THR_DETACHED | THR_NEW_LWP, &tid)) {
 		perror("thr_create");
 		free((void *) funcarg);
-		success = -1;
+		return -1;
 	}
 	return tid;
 }