delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/09/20/13:13:48

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT sourceware DOT cygnus DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
Message-Id: <199909201559.KAA04391@mercury.xraylith.wisc.edu>
To: Paul Berrevoets <paul AT swi DOT com>
cc: cygwin-list <cygwin AT sourceware DOT cygnus DOT com>
Subject: Re: lseek(0,...) in snapshot differs from b20.1
In-Reply-To: Your message of "Mon, 20 Sep 1999 12:42:12 EDT."
<37E663E4 DOT E800145B AT swi DOT com>
Date: Mon, 20 Sep 1999 10:59:09 -0500
From: Mumit Khan <khan AT xraylith DOT wisc DOT EDU>

Paul Berrevoets <paul AT swi DOT 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 AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019