Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758944AbXFJP4S (ORCPT ); Sun, 10 Jun 2007 11:56:18 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752640AbXFJP4J (ORCPT ); Sun, 10 Jun 2007 11:56:09 -0400 Received: from x35.xmailserver.org ([64.71.152.41]:1117 "EHLO x35.xmailserver.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752841AbXFJP4I (ORCPT ); Sun, 10 Jun 2007 11:56:08 -0400 X-AuthUser: davidel@xmailserver.org Date: Sun, 10 Jun 2007 08:56:06 -0700 (PDT) From: Davide Libenzi X-X-Sender: davide@alien.or.mcafeemobile.com To: Paul Mackerras cc: Kyle Moffett , Davide Libenzi , Alan Cox , Theodore Tso , Ulrich Drepper , Eric Dumazet , Linux Kernel Mailing List , Linus Torvalds , Andrew Morton , Ingo Molnar Subject: Re: [patch 7/8] fdmap v2 - implement sys_socket2 In-Reply-To: <18027.40637.672203.14305@cargo.ozlabs.ibm.com> Message-ID: References: <466741BD.20106@redhat.com> <20070607110432.73be7960@the-village.bc.nu> <20070607151243.22caab9e.dada1@cosmosbay.com> <466864F8.2050903@cosmosbay.com> <46686810.6030805@redhat.com> <466880A4.3090908@redhat.com> <20070608120746.GD12687@thunk.org> <20070608140150.6f31672f@the-village.bc.nu> <18026.15766.574693.200636@cargo.ozlabs.ibm.com> <463C79D8-88CB-492A-96FD-10C10D16C4B6@mac.com> <18027.40637.672203.14305@cargo.ozlabs.ibm.com> X-GPG-FINGRPRINT: CFAE 5BEE FD36 F65E E640 56FE 0974 BF23 270F 474E X-GPG-PUBLIC_KEY: http://www.xmailserver.org/davidel.asc MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 955 Lines: 28 On Sun, 10 Jun 2007, Paul Mackerras wrote: > > for (i = 0; i < NR_OPEN; i++) > > if (!fd_is_special_to_us(i)) > > close(i); > > > > Note that this is conceptually buggy, but occurs in several major C > > programming books, most of the major shells, and a lot of other > > software to boot. > > Buggy in what way? In the use of the NR_OPEN constant? That is typical daemonize code done by quite a few apps, and even described in many unix network programming books. Now say that before that you loaded a library that had an internal fd allocated to get some sort of services from the kernel (say an epoll fd). What happens when the library uses the cached apoll fd after that loop? - Davide - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/