From owner-freebsd-current@FreeBSD.ORG Tue Sep 16 14:45:04 2008 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AB85A106566C for ; Tue, 16 Sep 2008 14:45:04 +0000 (UTC) (envelope-from ache@nagual.pp.ru) Received: from nagual.pp.ru (nagual.pp.ru [194.87.13.69]) by mx1.freebsd.org (Postfix) with ESMTP id 262428FC22 for ; Tue, 16 Sep 2008 14:45:03 +0000 (UTC) (envelope-from ache@nagual.pp.ru) Received: from nagual.pp.ru (ache@localhost [127.0.0.1]) by nagual.pp.ru (8.14.3/8.14.3) with ESMTP id m8GEj2hR039882; Tue, 16 Sep 2008 18:45:02 +0400 (MSD) (envelope-from ache@nagual.pp.ru) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nagual.pp.ru; s=default; t=1221576302; bh=2uU5oknZEBbCOUTedldxoZ1Qw9FCqrMDOtGjV2m YbNs=; l=843; h=Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:In-Reply-To; b=A9zbJ4zWKnWDYslD2pjIjVoaW OBAKYqaxmjs7gRzEHyajj7Sv8iF3EoifBBEJBIZYPaFhN62K6nkmQV6oTYBL6NS/a14 0IV2X13ASzgopYp714pCwXRrxUX+ROurL1VvZMOrp1c4FWnwH5T2k7NjbAOFeE7CxAY INsQLk+yurq4= Received: (from ache@localhost) by nagual.pp.ru (8.14.3/8.14.3/Submit) id m8GEj2Qp039881; Tue, 16 Sep 2008 18:45:02 +0400 (MSD) (envelope-from ache) Date: Tue, 16 Sep 2008 18:45:02 +0400 From: Andrey Chernov To: Bob Bishop Message-ID: <20080916144502.GA39765@nagual.pp.ru> Mail-Followup-To: Andrey Chernov , Bob Bishop , current@freebsd.org References: <20080916140319.GA34447@nagual.pp.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) Cc: current@freebsd.org Subject: Re: Is fork() hook ever possible? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Sep 2008 14:45:04 -0000 On Tue, Sep 16, 2008 at 03:38:16PM +0100, Bob Bishop wrote: > Hi, > > On 16 Sep 2008, at 15:03, Andrey Chernov wrote: > > > I need some sort of fork() hook to detect that pid is changed to re- > > stir > > ar4random() after that (in the child), simple flag variable with > > child's pid is needed. > > > > Currently OpenBSD does almost that checking getpid() every time > > arc4random() called, but it is very slow way to use getpid() syscall > > repeatedly, about 12-15 times slower than just arc4random() without > > getpid(). > > > > Any ideas? > > How about something hacky using mmap()/minherit()? Could you please provide working low cost example to detect that we are in the child (pid changed or something else)? Calling getpid() as OpenBSD does definitely is very high cost. :( -- http://ache.pp.ru/