From owner-freebsd-stable@FreeBSD.ORG Mon Jun 1 15:58:17 2009 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8C1B01065675 for ; Mon, 1 Jun 2009 15:58:17 +0000 (UTC) (envelope-from cpghost@cordula.ws) Received: from fw.farid-hajji.net (fw.farid-hajji.net [213.146.115.42]) by mx1.freebsd.org (Postfix) with ESMTP id B39D68FC13 for ; Mon, 1 Jun 2009 15:58:11 +0000 (UTC) (envelope-from cpghost@cordula.ws) Received: from phenom.cordula.ws (phenom [192.168.254.60]) by fw.farid-hajji.net (Postfix) with ESMTP id 9554634D84; Mon, 1 Jun 2009 17:48:08 +0200 (CEST) Date: Mon, 1 Jun 2009 17:48:07 +0200 From: cpghost To: Vlad Galu Message-ID: <20090601154807.GB6065@phenom.cordula.ws> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.19 (2009-01-05) Cc: freebsd-stable@freebsd.org Subject: Re: Unnamed POSIX shared semaphores X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Jun 2009 15:58:18 -0000 On Mon, Jun 01, 2009 at 06:33:42PM +0300, Vlad Galu wrote: > Hello, > > According to sem_init(3), we can't have shared unnamed semaphores. > However, the following code snippet seems to work just fine: > > -- cut here -- > sem_t semaphore; > if (sem_init(&semaphore, 1, 10) < 0) > std::cout << "Couldn't init semaphore: " << > strerror(errno) << std::endl; > if (sem_wait(&semaphore) < 0) > std::cout << "Couldn't decrement semaphore: " << > strerror(errno) << std::endl; > int val; > sem_getvalue(&semaphore, &val); > std::cout << "Value is " << val << std::endl; > -- and here -- > > Is this a case where sem_init() silently reports success, or should be > the man page get an update? You may want to read the comments in /usr/src/lib/libc/gen/sem.c regarding sem_init(). But yes, the man page is somewhat unclear and I'm not sure the last paragraph is still totally accurate. > Thanks, > Vlad -cpghost. -- Cordula's Web. http://www.cordula.ws/