delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
DomainKey-Signature: | a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:message-id:date:from:mime-version:to:subject | |
:references:in-reply-to:content-type:content-transfer-encoding; | |
q=dns; s=default; b=MlhsQJZIrej+pmrxs4TYEvYIjpVAkDimme1xt4t7VrV | |
ffFZ4+bzDOknFLtsChxjHEyNJezT5W1FhmPpqP4vybgX2EkCefcLgI0cfAqHPMN0 | |
8QGSoLAgE79L62gPh5pCgD6oiF9pzUQTa4dxlqiugmKhpz7wC+QcNkgKfpVNLwrg | |
= | |
DKIM-Signature: | v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:message-id:date:from:mime-version:to:subject | |
:references:in-reply-to:content-type:content-transfer-encoding; | |
s=default; bh=4iJZ7PTxjHpDPcMfslB6lrB2NYQ=; b=KR6fTkLABTALk1cci | |
9JRY3tJ/qonXYvQkeIxY6aZ16lEHS3VPquqSc1fsRCeUHYaXAgec3WxPpzATCMUv | |
v+xGzD6xR9ZicwiMKc2GaM4XVpQ4+LDrn1OkSEPCXsEo5QLS9UdOnZnfz3L9RiqF | |
ubimMMib3rm08tqE5BxtMjtPA4= | |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
Authentication-Results: | sourceware.org; auth=none |
X-Virus-Found: | No |
X-Spam-SWARE-Status: | No, score=-0.7 required=5.0 tests=AWL,BAYES_40,RP_MATCHES_RCVD autolearn=ham version=3.3.2 |
X-HELO: | Ishtar.hs.tlinx.org |
Message-ID: | <53F12A72.2090805@tlinx.org> |
Date: | Sun, 17 Aug 2014 15:19:30 -0700 |
From: | Linda Walsh <cygwin AT tlinx DOT org> |
User-Agent: | Thunderbird |
MIME-Version: | 1.0 |
To: | cygwin AT cygwin DOT com |
Subject: | Re: Bash uses lseek while reading from serial device |
References: | <20140816184739 DOT 3078D27C7E AT mail DOT csclub DOT uwaterloo DOT ca> |
In-Reply-To: | <20140816184739.3078D27C7E@mail.csclub.uwaterloo.ca> |
X-IsSubscribed: | yes |
Being a bit of a busybody... I forwarded this to the bash list and chet responded there... so forwarding it back here... not sure what isatty is supposed to do with a serial line, let alone one on windows... -------- Original Message -------- Subject: Re: Fwd: Bash uses lseek while reading from serial device Date: Sun, 17 Aug 2014 18:12:23 -0400 From: Chet Ramey Organization: ITS, Case Western Reserve University To: Linda Walsh, bug-bash CC: chet.ramey References: <53F041FD DOT 3050509 AT tlinx DOT org> On 8/17/14, 1:47 AM, Linda Walsh wrote: > ?? Could this be a cygwin bug? It's hard to see why cygwin > would start using lseek calls when running bash unless bash called > them... but then tha's not to say something else entirely may be going on as > this is running on Windows... ;-/ The original poster's speculation is correct. Bash is not allowed to read more input from stdin than it actually consumes, so commands that it runs get the intended input. To that end, it tries to detect whether or not the fd it is using for standard input is seekable: if it is, bash assumes that it can correctly position the file pointer by seeking backwards; if it is not, bash reads a character at a time. Bash uses lseek to the current file position to check this. If the lseek returns -1/EPIPE, bash assumes the fd is not seekable. If it returns 0, bash assumes that it can move around freely. Since bash is trying to seek backwards in the file, stdin is either a regular file or a tty (in which case bash assumes that reads are newline-delimited by the device driver). I suspect what happens is that isatty() returns 1 for serial devices, but reads are not newline-delimited. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU chet AT case DOT edu http://cnswww.cns.cwru.edu/~chet/ -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |