Date: Tue, 14 Sep 2004 10:02:35 +0200 (CEST) From: Harti Brandt <harti@freebsd.org> To: Jun Kuriyama <kuriyama@imgsrc.co.jp> Cc: arch@freebsd.org Subject: Re: stderr is seekable? (lseek(2)) Message-ID: <20040914094556.C77243@beagle.kn.op.dlr.de> In-Reply-To: <7macvto7wn.wl@black.imgsrc.co.jp> References: <7macvto7wn.wl@black.imgsrc.co.jp>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <sys/types.h> JK>#include <unistd.h> JK>#include <stdio.h> JK>#include <errno.h> 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>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040914094556.C77243>