[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: threads question





> -----Original Message-----
> From: Oleg Goldshmidt [mailto:ogoldshmidt@computer.org]
> Sent: Tuesday, November 27, 2001 1:58 AM
> To: linux-il@linux.org.il
> Subject: threads question
> 
> 
> 
> OK, I have my own programming question. Not a homework. I am also
> posting it to comp.unix.programming, but this list can be more
> responsive.
> 
> I have the following trivial piece of code that I am trying to
> compile with g++ (gcc-2.96-98) on RH 7.2 (Linux 2.4.9-13 on i686).
> The code looks like C, but the real code I am debugging is C++, and
> exhibits the same problem on RH7.2 and on a fully updated RH7.1
> (Linux 2.4.9-12 on i686).
> 
> ///////////////////// pth.cpp ////////////////////////////////
> 
> #include <stdlib.h>
> #include <stdio.h>
> #include <string.h>
> #include <errno.h>
> #include <pthread.h>
> 
> static void* start(void* arg)
> {
> 	int c = *((int*)arg);
> 	free(arg);
> 	if (pthread_detach(pthread_self()) != 0)
> 	{
> 		fprintf(stderr,"Error: %s\n",strerror(errno));
> 		exit(EXIT_FAILURE);
> 	}
> 	printf("The argument is %d\n",c);
> 	return NULL;
> }

AFAIK, you should not "return NULL; " from a pthread, but rather
"pthread_exit( NULL ); "

=================================================================
To unsubscribe, send mail to linux-il-request@linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request@linux.org.il