Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Oct 2001 16:09:52 -0500
From:      Chris Costello <chris@FreeBSD.ORG>
To:        Oleg Golovanov <olmi@home.krasnoyarsk.ru>
Cc:        freebsd-questions@FreeBSD.ORG, freebsd-hackers@FreeBSD.ORG
Subject:   Re: Question about pthread
Message-ID:  <20011003160951.E57938@holly.calldei.com>
In-Reply-To: <3BBB77A7.5C4B129E@home.krasnoyarsk.ru>; from olmi@home.krasnoyarsk.ru on Thu, Oct 04, 2001 at 04:40:07AM %2B0800
References:  <3BBB77A7.5C4B129E@home.krasnoyarsk.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thursday, October 04, 2001, Oleg Golovanov wrote:
> static void *coms(void *arg)
> {
>   pthread_detach(pthread_self());
>   write((int)arg, "Test", sizeof("test"));
>   close((int)arg);
>   return(NULL);
> }

   For starters, this function should be rewritten as

static void *coms(void *arg)
{
   int fd;

   fd = *(int *)arg;
   pthread_detach(pthread_self());
   write(fd, "Test", 4);
   close(fd);
   return (NULL);
}

   Because you're passing the _address_ of `confd', not the
value.  You must first cast arg to an int pointer, and then
dereference it (and assign its value to `fd').

-- 
+-------------------+---------------------------------------------------+
| Chris Costello    | CCITT - Can't Conceive Intelligent Thoughts Today |
| chris@FreeBSD.org |                                                   |
+-------------------+---------------------------------------------------+

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?20011003160951.E57938>