From owner-freebsd-hackers@FreeBSD.ORG Fri May 29 09:49:23 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 1A3491065673; Fri, 29 May 2009 09:49:23 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (tim.des.no [194.63.250.121]) by mx1.freebsd.org (Postfix) with ESMTP id A4A2F8FC17; Fri, 29 May 2009 09:49:22 +0000 (UTC) (envelope-from des@des.no) Received: from ds4.des.no (des.no [84.49.246.2]) by smtp.des.no (Postfix) with ESMTP id ED43F6D41C; Fri, 29 May 2009 11:49:21 +0200 (CEST) Received: by ds4.des.no (Postfix, from userid 1001) id BEEBC844EE; Fri, 29 May 2009 11:49:21 +0200 (CEST) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: Alfred Perlstein References: <4A14F58F.8000801@rawbw.com> <4A1594DA.2010707@rawbw.com> <86ljoig08o.fsf@ds4.des.no> <20090528213017.GX67847@elvis.mu.org> Date: Fri, 29 May 2009 11:49:21 +0200 In-Reply-To: <20090528213017.GX67847@elvis.mu.org> (Alfred Perlstein's message of "Thu, 28 May 2009 14:30:17 -0700") Message-ID: <863aaow866.fsf@ds4.des.no> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 09:49:23 -0000 Alfred Perlstein writes: > Dag-Erling Sm=C3=B8rgrav writes: > > Usually, what you see is closer to this: > >=20 > > if ((pid =3D fork()) =3D=3D 0) { > > for (int fd =3D 3; fd < getdtablesize(); ++fd) > > (void)close(fd); > > execve(path, argv, envp); > > _exit(1); > > } > > I'm probably missing something, but couldn't you iterate=20 > 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. DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no