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 [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message