From owner-freebsd-current@FreeBSD.ORG Tue Sep 16 14:54:01 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 4E02B106566C for ; Tue, 16 Sep 2008 14:54:01 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-gx0-f17.google.com (mail-gx0-f17.google.com [209.85.217.17]) by mx1.freebsd.org (Postfix) with ESMTP id E7CCA8FC0C for ; Tue, 16 Sep 2008 14:53:55 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: by gxk10 with SMTP id 10so25495008gxk.19 for ; Tue, 16 Sep 2008 07:53:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references :x-google-sender-auth; bh=IzaR1TlTflAHPjKgF8AG4EJHS1Sld4NV4EThfFhbX2w=; b=U//z3cpZ8z5wWksOlLEkfYqK6hhfMXojB1NwjoXtT/JdVPT1vFNZQX6LvT2Pr+iblC RA2tWGdskpJgDm0RnuU1PwS2bCCdPumm1P0KMox8amXv2+dtxJ0qbHs9QrkqkTXajItn QO79njKC95RRh291u2WsYzAL84hutzn2P14Vg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references:x-google-sender-auth; b=dxCAhzevPe0dDI0C8NnJcWNZsgSsKDD3Tt0ClfIz+U5JoswORY59X6ZGvjfbwMV/Ld dsWrj3JHXmaDMLPhZYaWXJ9wimm7KqBuaacv0/PJQtfNa1d/sXL+PJnj3bAtETarsI21 fe9jWzKGl3pOBArEst56xMpPoTA7Dh2FAaw7s= Received: by 10.103.211.3 with SMTP id n3mr771428muq.43.1221576834083; Tue, 16 Sep 2008 07:53:54 -0700 (PDT) Received: by 10.103.239.14 with HTTP; Tue, 16 Sep 2008 07:53:54 -0700 (PDT) Message-ID: <3bbf2fe10809160753o7e5e8a78q7c6bd44c02bfd5c2@mail.gmail.com> Date: Tue, 16 Sep 2008 16:53:54 +0200 From: "Attilio Rao" Sender: asmrookie@gmail.com To: "Andrey Chernov" , "Bob Bishop" , current@freebsd.org In-Reply-To: <20080916144502.GA39765@nagual.pp.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20080916140319.GA34447@nagual.pp.ru> <20080916144502.GA39765@nagual.pp.ru> X-Google-Sender-Auth: 40842ea934c8271e Cc: 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:54:01 -0000 2008/9/16, Andrey Chernov : > 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. :( An idea would be to implement a shared page between process and system which exports such informations. I'm sure we have a SoC project (2007) implementing this and perforce branches for it, I'm just not sure how far it did end. Thanks, Attilio -- Peace can only be achieved by understanding - A. Einstein