lseek and sockets/console

Robert Collins
Mon Mar 18 18:13:00 GMT 2002

lseek on stdin returns EBADF at the moment, according to 1003.x it looks
like it should return -1 with errno ESPIPE.

For sockets it returns 0 always, again -1 with errno=ESPIPE is correct.
Likewise for tty's.

I need stdin to return -1, errno ESPIPE so I'll be fixing that up (I'll
submit a patch, I'm not familiar with that bit of source at the moment),
but am seeking thoughts on the rest.


The lseek( ) function shall fail if:
[EBADF] The fildes argument is not an open file descriptor.
[EINVAL] The whence argument is not a proper value, or the resulting
file offset would
be negative for a regular file, block special file, or directory.
[EOVERFLOW] The resulting file offset would be a value which cannot be
correctly in an object of type off_t.
[ESPIPE] The fildes argument is associated with a pipe, FIFO, or socket.

More information about the Cygwin-developers mailing list