From owner-freebsd-hackers@FreeBSD.ORG Fri May 29 19:31:37 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EDCB5106567B for ; Fri, 29 May 2009 19:31:37 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.freebsd.org (Postfix) with ESMTP id DA23F8FC22 for ; Fri, 29 May 2009 19:31:37 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1192) id 94EA01A3C3B; Fri, 29 May 2009 12:31:37 -0700 (PDT) Date: Fri, 29 May 2009 12:31:37 -0700 From: Alfred Perlstein To: Dag-Erling Sm??rgrav Message-ID: <20090529193137.GH67847@elvis.mu.org> References: <4A14F58F.8000801@rawbw.com> <4A1594DA.2010707@rawbw.com> <86ljoig08o.fsf@ds4.des.no> <20090528213017.GX67847@elvis.mu.org> <863aaow866.fsf@ds4.des.no> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <863aaow866.fsf@ds4.des.no> User-Agent: Mutt/1.4.2.3i Cc: Nate Eldredge , yuri@rawbw.com, freebsd-hackers@freebsd.org Subject: Re: Why kernel kills processes that run out of memory instead of just failing memory allocation system calls? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 May 2009 19:31:38 -0000 * Dag-Erling Sm??rgrav [090529 02:49] wrote: > Alfred Perlstein writes: > > Dag-Erling Sm??rgrav writes: > > > Usually, what you see is closer to this: > > > > > > if ((pid = fork()) == 0) { > > > for (int fd = 3; fd < getdtablesize(); ++fd) > > > (void)close(fd); > > > execve(path, argv, envp); > > > _exit(1); > > > } > > > > I'm probably missing something, but couldn't you iterate > > in the parent setting the close-on-exec flag then vfork? > > This is an example, Alfred. Like most examples, it is greatly > simplified. I invite you to peruse the source to find real-world > instances of non-trivial fork() / execve() usage. It wasn't meant to critisize, just ask a question for the specific instance because it made me curious. I know how bad it can be with vfork as I observed a few fixes involving mistaken use of vfork at another job. So yes, there's more than one way to skin a cat for this particular example... but in practice using vfork()+exec() is hard to get right? -- - Alfred Perlstein