This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
Re: lseek(0,...) in snapshot differs from b20.1
- To: Paul Berrevoets <paul at swi dot com>
- Subject: Re: lseek(0,...) in snapshot differs from b20.1
- From: Mumit Khan <khan at xraylith dot wisc dot EDU>
- Date: Mon, 20 Sep 1999 10:59:09 -0500
- cc: cygwin-list <cygwin at sourceware dot cygnus dot com>
Paul Berrevoets <paul@swi.com> writes:
> #include <sys/types.h>
> #include <unistd.h>
> #include <errno.h>
> int
> main()
> {
> int rc = lseek(0, (off_t)0, SEEK_CUR);
> printf("%d %d\n", rc, rc < 0 ? errno : 0);
> return 0;
> }
>
> Ouput using b20.1:
> 0 0
>
> Output using snapshot 1999-09-17:
> -1 9
>
> If this change is intentional, could you please explain the rationale?
POSIX says something like "Some devices are incapable of seeking and
POSIX does not specify which devices must support it." Linux for example
will set the errno to ESPIPE with your code (which Cygwin should follow
as well instead of using ENODEV); HPUX will return the total number
of total number of bytes written to the descriptor and so on.
Simply put, assuming that stdin is seekable is non-portable and should
be avoided at all costs. I tend to use isatty(), and avoid calling lseek
on a tty device.
Regards,
Mumit
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com