From owner-freebsd-hackers Wed Oct 3 14:11: 4 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from holly.dyndns.org (adsl-208-191-149-224.dsl.hstntx.swbell.net [208.191.149.224]) by hub.freebsd.org (Postfix) with ESMTP id EE01337B403; Wed, 3 Oct 2001 14:10:58 -0700 (PDT) Received: (from chris@localhost) by holly.dyndns.org (8.11.4/8.9.3) id f93L9sI70880; Wed, 3 Oct 2001 16:09:54 -0500 (CDT) (envelope-from chris) Date: Wed, 3 Oct 2001 16:09:52 -0500 From: Chris Costello To: Oleg Golovanov Cc: freebsd-questions@FreeBSD.ORG, freebsd-hackers@FreeBSD.ORG Subject: Re: Question about pthread Message-ID: <20011003160951.E57938@holly.calldei.com> Reply-To: chris@FreeBSD.ORG References: <3BBB77A7.5C4B129E@home.krasnoyarsk.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <3BBB77A7.5C4B129E@home.krasnoyarsk.ru>; from olmi@home.krasnoyarsk.ru on Thu, Oct 04, 2001 at 04:40:07AM +0800 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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