Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758570AbYJJLbg (ORCPT ); Fri, 10 Oct 2008 07:31:36 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757958AbYJJLbY (ORCPT ); Fri, 10 Oct 2008 07:31:24 -0400 Received: from mail-in-07.arcor-online.net ([151.189.21.47]:37620 "EHLO mail-in-07.arcor-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757892AbYJJLbX (ORCPT ); Fri, 10 Oct 2008 07:31:23 -0400 From: Bodo Eggert <7eggert@gmx.de> Subject: Re: dup2() vs dup3() inconsistency when To: mtk.manpages@gmail.com, "H. Peter Anvin" , Ulrich Drepper , Al Viro , LKML Reply-To: 7eggert@gmx.de Date: Fri, 10 Oct 2008 13:42:11 +0200 References: User-Agent: KNode/0.10.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit Message-Id: X-be10.7eggert.dyndns.org-MailScanner-Information: See www.mailscanner.info for information X-be10.7eggert.dyndns.org-MailScanner: Found to be clean X-be10.7eggert.dyndns.org-MailScanner-From: 7eggert@gmx.de Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1128 Lines: 26 Michael Kerrisk wrote: > Well, as long as we are fixing the dup3() interface in the way that Al > and Ulrich have suggested, what about another fix: > > give an error if newfd is already open, thus forcing the user to do an > explicit close > > ? > > This silent close in dup2() is an implementation blemish. Why not eliminate > it? I think it might be usefull: Thread B does some logging to fd 42 Thread A switches the logfile by creating a new file, writing a header and then does dup3(fd, 42, O_WRONLY|O_APPEND|O_CLOEXEC); close(fd); (Off cause this is not yet implemented, O_RDONLY would give some problems, O_CLOEXEC alone might be better done while open()ing the file, ... but you get the idea.) BTW: I think dup3(fd, -1, flags) should use the file descriptor dup() would return. Or should there be a dupf(fd, flags) syscall instead? -- 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/