Date: Thu, 04 Oct 2001 04:40:07 +0800 From: Oleg Golovanov <olmi@home.krasnoyarsk.ru> To: freebsd-questions@freebsd.org, freebsd-hackers@freebsd.org Subject: Question about pthread Message-ID: <3BBB77A7.5C4B129E@home.krasnoyarsk.ru>
next in thread | raw e-mail | index | archive | help
Dear Sirs: I am using FreeBSD-2.2.8 and after calling pthread_create() my programs get sigfault (SIGSEGV) and exited with core dump. I should like to ask if somebody know the solve of this problem. My example of using pthread is included below. I ask to answer me directly on my e-mail. Oleg ---- #include <errno.h> #include <pthread.h> #include <sys/socket.h> #include <sys/un.h> #define socklen_t unsigned int static void *coms(void *arg) { pthread_detach(pthread_self()); write((int)arg, "Test", sizeof("test")); close((int)arg); return(NULL); } int main(int argc, char **argv) { int *confd, len, lisfd; struct sockaddr_un *client, saun; lisfd = socket(AF_UNIX, SOCK_STREAM, 0); unlink("/tmp/TS"); saun.sun_family = AF_UNIX; strcpy(saun.sun_path, "/tmp/TS"); bind(lisfd, (struct sockaddr *) &saun, sizeof(struct sockaddr_un)); listen(lisfd, 2); client = (struct sockaddr_un *)malloc(sizeof(saun)); confd = (int *)malloc(sizeof(int)); for ( ; ; ) { len = sizeof(saun); *confd = accept(lisfd, (struct sockaddr *) client, &len); pthread_create(NULL, NULL, &coms, confd); } return(0); } ---- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3BBB77A7.5C4B129E>