From owner-freebsd-arch@FreeBSD.ORG Tue Sep 14 08:02:43 2004 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CE4A016A4CE for ; Tue, 14 Sep 2004 08:02:43 +0000 (GMT) Received: from n33.kp.t-systems-sfr.com (n33.kp.t-systems-sfr.com [129.247.16.33]) by mx1.FreeBSD.org (Postfix) with ESMTP id E835443D46 for ; Tue, 14 Sep 2004 08:02:42 +0000 (GMT) (envelope-from harti@freebsd.org) Received: from n81.sp.op.dlr.de (n81g.sp.op.dlr.de [129.247.163.1]) i8E82W2438474; Tue, 14 Sep 2004 10:02:36 +0200 Received: from zeus.nt.op.dlr.de (zeus.nt.op.dlr.de [129.247.173.3]) i8E82VI114382; Tue, 14 Sep 2004 10:02:31 +0200 Received: from beagle.kn.op.dlr.de (opkndnwsbsd178 [129.247.173.178]) by zeus.nt.op.dlr.de (8.11.7+Sun/8.9.1) with ESMTP id i8E82Se01438; Tue, 14 Sep 2004 10:02:30 +0200 (MET DST) Date: Tue, 14 Sep 2004 10:02:35 +0200 (CEST) From: Harti Brandt X-X-Sender: brandt@beagle.kn.op.dlr.de To: Jun Kuriyama In-Reply-To: <7macvto7wn.wl@black.imgsrc.co.jp> Message-ID: <20040914094556.C77243@beagle.kn.op.dlr.de> References: <7macvto7wn.wl@black.imgsrc.co.jp> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: arch@freebsd.org Subject: Re: stderr is seekable? (lseek(2)) X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Harti Brandt List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Sep 2004 08:02:43 -0000 On Tue, 14 Sep 2004, Jun Kuriyama wrote: JK> JK>When I tested this program, it finished successfully. But on Linux, JK>lseek(2) returns -1 and errno is ESPIPE. JK> JK>I expected to be returned ESPIPE as Linux did. Is our behavior JK>correct, or there is something wrong? Posix requires to return EPIPE when the file is a socket, pipe or fifo. I assume you start the program with stderr connected to tty? This case seems not to be specified, so we are free to return whatever we want (but should probably document it). There is only one place in Posix that talks about seeking and terminals: in the read() man page. But this place does not place any requirement on lseek(), but on pread() with an implied seek (to return an error). harti JK> JK>----- JK>#include JK>#include JK>#include JK>#include JK> JK>int JK>main(int argc, char **argv) JK>{ JK> off_t r = lseek(2, 1, SEEK_CUR); JK> printf("r=%d\n", r); JK> if (r == -1) { JK> printf("errno=%d, %s\n", errno, strerror(errno)); JK> } JK> return 0; JK>} JK>----- JK> JK> JK>