From owner-freebsd-questions Wed Oct 3 13:33:51 2001 Delivered-To: freebsd-questions@freebsd.org Received: from home.krasnoyarsk.ru (free.home.krasnoyarsk.ru [195.161.57.59]) by hub.freebsd.org (Postfix) with ESMTP id C8EEA37B401; Wed, 3 Oct 2001 13:33:40 -0700 (PDT) Received: from home.krasnoyarsk.ru (localhost.home.krasnoyarsk.ru [127.0.0.1]) by home.krasnoyarsk.ru (8.9.3/8.9.3) with ESMTP id EAA01371; Thu, 4 Oct 2001 04:40:07 +0800 (KRSS) Message-ID: <3BBB77A7.5C4B129E@home.krasnoyarsk.ru> Date: Thu, 04 Oct 2001 04:40:07 +0800 From: Oleg Golovanov Organization: Home Networks of Krasnoyarsk City X-Mailer: Mozilla 4.7 [en] (X11; I; FreeBSD 2.2.8-RELEASE i386) X-Accept-Language: ru, en MIME-Version: 1.0 To: freebsd-questions@freebsd.org, freebsd-hackers@freebsd.org Subject: Question about pthread Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 #include #include #include #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-questions" in the body of the message