public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Bash uses lseek while reading from serial device
@ 2014-08-16 18:47 Ross Ridge
  2014-08-17 22:19 ` Linda Walsh
  0 siblings, 1 reply; 5+ messages in thread
From: Ross Ridge @ 2014-08-16 18:47 UTC (permalink / raw)
  To: cygwin

I've encountered a problem where bash will use lseek to seek backwards
on a serial device.  This results in data being lost when large chuncks
of data are being read at once.  This doesn't happen when reading from
a pipe, so it appears that bash is unable to detect that serial devices
are unseekable.  I'm not sure if this a bash problem, a problem the
Cygwin port of bash or the Cygwin DLL.

Here's a script that demonstrates the problem:

while :
do
 	IFS="" read -r line 
	case "$line" in
	quit*)
		break
		;;
	*)
		echo "recieved line: $line"
		;;
	esac
done < /dev/ttyS0

When the script is feed a lot of data over the serial port (a physical
tradtional PC serial port) the beginning of lines will be discarded
because of the lseek calls.

Changing the script to read from a pipe instead fixes the problem:

cat < /dev/ttyS0 | while :
do
 	IFS="" read -r line 
	...
done

Running strace on bash reveals that bash tries to use lseek to seek
backwards on the serial device, presumably because it has read past the
end of the line.

  415 5605467 [main] bash 6104 read: 1 = read(0, 0x100497520, 128)
  378 5605845 [main] bash 6104 read: read(0, 0x100497520, 128) blocking
  385 5606230 [main] bash 6104 fhandler_serial::raw_read: ulen 128, vmin_ 0, vtime_ 0, hEvent 0x208
  410 5606640 [main] bash 6104 fhandler_serial::raw_read: inq 7
  375 5607015 [main] bash 6104 fhandler_serial::raw_read: vtime_ 0, vmin_ 0, n 7, tot 7
  400 5607415 [main] bash 6104 fhandler_base::read: returning 6, text mode
  234 5607649 [main] bash 6104 read: 6 = read(0, 0x100497520, 128)
  262 5607911 [main] bash 6104 lseek64: 0 = lseek(0, -5, 1)

Here are the results from running cygcheck -s -v -r

Cygwin Configuration Diagnostics
Current System Time: Sat Aug 16 19:29:28 2014

Windows 7 Home Premium Ver 6.1 Build 7601 Service Pack 1

Path:	E:\util\cygwin\usr\local\bin
	E:\util\cygwin\bin
	E:\bin
	C:\Windows\system32
	C:\Windows
	C:\Windows\System32\WindowsPowerShell\v1.0

Output from E:\util\cygwin\bin\id.exe
UID: 1001(Ross Ridge)      GID: 513(None)
513(None)                  559(Performance Log Users)
545(Users)

SysDir: C:\Windows\system32
WinDir: C:\Windows

USER = 'Ross Ridge'
PWD = '/cygdrive/e/src/test'
HOME = '/cygdrive/c/Users/Ross Ridge'

HOMEPATH = '\Users\Ross Ridge'
AV_APPDATA = 'C:\Users\ROSSRI~1\AppData\Roaming'
APPDATA = 'C:\Users\Ross Ridge\AppData\Roaming'
ProgramW6432 = 'C:\Program Files'
HOSTNAME = 'QON'
SHELL = '/bin/bash'
TERM = 'cygwin'
_NT_SYMBOL_PATH = 'SRV*e:\dbg*http://msdl.microsoft.com/download/symbols'
PROCESSOR_IDENTIFIER = 'Intel64 Family 6 Model 30 Stepping 5, GenuineIntel'
PROFILEREAD = 'true'
WINDIR = 'C:\Windows'
PUBLIC = 'C:\Users\Public'
OLDPWD = '/cygdrive/c/Users/Ross Ridge'
ORIGINAL_PATH = '/cygdrive/e/bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0'
USERDOMAIN = 'QON'
CommonProgramFiles(x86) = 'C:\Program Files (x86)\Common Files'
OS = 'Windows_NT'
ALLUSERSPROFILE = 'C:\ProgramData'
!:: = '::\'
TEMP = '/tmp'
COMMONPROGRAMFILES = 'C:\Program Files\Common Files'
QTJAVA = 'E:\util\quicktime\QTSystem\QTJava.zip'
USERNAME = 'Ross Ridge'
PROCESSOR_LEVEL = '6'
ProgramFiles(x86) = 'C:\Program Files (x86)'
PSModulePath = 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\'
FP_NO_HOST_CHECK = 'NO'
SYSTEMDRIVE = 'C:'
AMDAPPSDKROOT = 'C:\Program Files (x86)\AMD APP\'
LANG = 'en_US.UTF-8'
VS120COMNTOOLS = 'E:\util\vs12\Common7\Tools\'
USERPROFILE = 'C:\Users\Ross Ridge'
TZ = 'America/New_York'
PS1 = '\w$ '
LOGONSERVER = '\\QON'
CommonProgramW6432 = 'C:\Program Files\Common Files'
PROCESSOR_ARCHITECTURE = 'AMD64'
LOCALAPPDATA = 'C:\Users\Ross Ridge\AppData\Local'
!C: = 'C:\Users\Ross Ridge'
ProgramData = 'C:\ProgramData'
EXECIGNORE = '*.dll'
SHLVL = '1'
PATHEXT = '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC'
HOMEDRIVE = 'C:'
VBOX_MSI_INSTALL_PATH = 'E:\util\virtualbox\'
PROMPT = '$p$g '
COMSPEC = 'C:\Windows\system32\cmd.exe'
TMP = '/tmp'
SYSTEMROOT = 'C:\Windows'
LOGNAME = 'unknown'
PRINTER = 'Artisan 730(Network)'
PROCESSOR_REVISION = '1e05'
CLASSPATH = '.;E:\util\quicktime\QTSystem\QTJava.zip'
VS100COMNTOOLS = 'E:\util\vs10\Common7\Tools\'
!E: = 'E:\util\cygwin\bin'
INFOPATH = '/usr/local/info:/usr/share/info:/usr/info'
PROGRAMFILES = 'C:\Program Files'
NUMBER_OF_PROCESSORS = '4'
SESSIONNAME = 'Console'
COMPUTERNAME = 'QON'
_ = '/usr/bin/cygcheck'

HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\Program Options
HKEY_CURRENT_USER\Software\Cygwin
HKEY_CURRENT_USER\Software\Cygwin\Installations
  (default) = '\??\E:\util\cygwin'
HKEY_CURRENT_USER\Software\Cygwin\Program Options
HKEY_CURRENT_USER\Software\Cygwin\setup
HKEY_LOCAL_MACHINE\SOFTWARE\Cygwin
HKEY_LOCAL_MACHINE\SOFTWARE\Cygwin\Installations
  (default) = '\??\e:\util\cygwin'
HKEY_LOCAL_MACHINE\SOFTWARE\Cygwin\Program Options
HKEY_LOCAL_MACHINE\SOFTWARE\Cygwin\setup
  (default) = 'e:\util\cygwin'
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Cygwin
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Cygwin\Installations
  (default) = '\??\e:\util\cygwin'
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Cygwin\Program Options
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Cygwin\setup
  (default) = 'e:\util\cygwin'

obcaseinsensitive set to 1

Cygwin installations found in the registry:
  System: Key: d3878126d581d849 Path: e:\util\cygwin
  User:   Key: d3878126d581d849 Path: E:\util\cygwin

a:  fd             N/A    N/A                    
c:  hd  NTFS    102299Mb  95% CP CS UN PA FC     Windows 7 SSD
e:  hd  NTFS   1837456Mb 100% CP CS UN PA FC     Util
f:  hd  exFAT  1023873Mb  98% CP    UN           Games
m:  net            N/A    N/A                    
q:  cd             N/A    N/A                    
r:  cd             N/A    N/A                    
u:  net            N/A    N/A                    
z:  hd  NTFS        99Mb  29% CP CS UN PA FC     SSD System Reserved

E:\util\cygwin      /          system  binary,auto
E:\util\cygwin\bin  /usr/bin   system  binary,auto
E:\util\cygwin\lib  /usr/lib   system  binary,auto
cygdrive prefix     /cygdrive  user    binary,posix=0,auto

Found: E:\util\cygwin\bin\awk
Found: E:\bin\awk.exe
Warning: E:\util\cygwin\bin\awk hides E:\bin\awk.exe
 -> E:\util\cygwin\bin\gawk.exe
Found: E:\util\cygwin\bin\bash.exe
Found: E:\util\cygwin\bin\cat.exe
Found: E:\util\cygwin\bin\cp.exe
Found: E:\util\cygwin\bin\cpp.exe
Not Found: crontab
Found: E:\util\cygwin\bin\find.exe
Found: C:\Windows\system32\find.exe
Warning: E:\util\cygwin\bin\find.exe hides C:\Windows\system32\find.exe
Found: E:\util\cygwin\bin\gcc.exe
Found: E:\util\cygwin\bin\gdb.exe
Found: E:\util\cygwin\bin\grep.exe
Found: E:\bin\grep.exe
Warning: E:\util\cygwin\bin\grep.exe hides E:\bin\grep.exe
Found: E:\util\cygwin\bin\kill.exe
Found: E:\util\cygwin\bin\ld.exe
Found: E:\util\cygwin\bin\ls.exe
Found: E:\util\cygwin\bin\make.exe
Found: E:\bin\make.exe
Warning: E:\util\cygwin\bin\make.exe hides E:\bin\make.exe
Found: E:\util\cygwin\bin\mv.exe
Not Found: patch
Found: E:\util\cygwin\bin\perl.exe
Found: E:\util\cygwin\bin\rm.exe
Found: E:\util\cygwin\bin\sed.exe
Not Found: ssh
Found: E:\util\cygwin\bin\sh.exe
Found: E:\util\cygwin\bin\tar.exe
Found: E:\bin\tar.exe
Warning: E:\util\cygwin\bin\tar.exe hides E:\bin\tar.exe
Found: E:\util\cygwin\bin\test.exe
Found: E:\util\cygwin\bin\vi.exe
Not Found: vim

  127k 2013/06/23 E:\util\cygwin\bin\cygapr-1-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygapr-1-0.dll" v0.0 ts=2013-06-23 18:53
  115k 2013/08/11 E:\util\cygwin\bin\cygaprutil-1-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygaprutil-1-0.dll" v0.0 ts=2013-08-11 19:13
   38k 2013/07/19 E:\util\cygwin\bin\cygargp-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygargp-0.dll" v0.0 ts=2013-07-19 15:07
   87k 2014/06/01 E:\util\cygwin\bin\cygatomic-1.dll - os=4.0 img=0.0 sys=5.2
                  "cygatomic-1.dll" v0.0 ts=1970-01-01 00:00
   16k 2013/03/26 E:\util\cygwin\bin\cygattr-1.dll - os=4.0 img=0.0 sys=5.2
                  "cygattr-1.dll" v0.0 ts=2013-03-26 18:26
  172k 2014/07/09 E:\util\cygwin\bin\cygblkid-1.dll - os=4.0 img=0.0 sys=5.2
                  "cygblkid-1.dll" v0.0 ts=1970-01-01 00:00
   64k 2013/03/07 E:\util\cygwin\bin\cygbz2-1.dll - os=4.0 img=0.0 sys=5.2
                  "cygbz2-1.dll" v0.0 ts=2013-03-07 02:54
  117k 2013/05/05 E:\util\cygwin\bin\cygcloog-isl-4.dll - os=4.0 img=0.0 sys=5.2
                  "cygcloog-isl-4.dll" v0.0 ts=2013-05-05 16:41
   12k 2014/06/09 E:\util\cygwin\bin\cygcom_err-2.dll - os=4.0 img=0.0 sys=5.2
                  "cygcom_err-2.dll" v0.0 ts=1970-01-01 00:00
    9k 2013/03/07 E:\util\cygwin\bin\cygcrypt-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygcrypt-0.dll" v0.0 ts=2013-03-07 09:29
 1749k 2014/08/07 E:\util\cygwin\bin\cygcrypto-1.0.0.dll - os=4.0 img=0.0 sys=5.2
                  "cygcrypto-1.0.0.dll" v0.0 ts=1970-01-01 00:00
 1526k 2013/03/08 E:\util\cygwin\bin\cygdb-5.3.dll - os=4.0 img=0.0 sys=5.2
                  "cygdb-5.3.dll" v0.0 ts=2013-03-08 07:55
  111k 2013/03/08 E:\util\cygwin\bin\cygdb_cxx-5.3.dll - os=4.0 img=0.0 sys=5.2
                  "cygdb_cxx-5.3.dll" v0.0 ts=2013-03-08 07:56
  472k 2013/03/08 E:\util\cygwin\bin\cygdb_sql-5.3.dll - os=4.0 img=0.0 sys=5.2
                  "cygdb_sql-5.3.dll" v0.0 ts=2013-03-08 07:58
  147k 2013/07/31 E:\util\cygwin\bin\cygexpat-1.dll - os=4.0 img=0.0 sys=5.2
                  "cygexpat-1.dll" v0.0 ts=2013-07-31 22:53
   22k 2013/05/12 E:\util\cygwin\bin\cygffi-6.dll - os=4.0 img=0.0 sys=5.2
                  "cygffi-6.dll" v0.0 ts=2013-05-12 22:53
   56k 2014/05/26 E:\util\cygwin\bin\cygformw-10.dll - os=4.0 img=0.0 sys=5.2
                  "cygformw-10.dll" v0.0 ts=1970-01-01 00:00
   67k 2014/06/01 E:\util\cygwin\bin\cyggcc_s-seh-1.dll - os=4.0 img=0.0 sys=5.2
                  "cyggcc_s-seh-1.dll" v0.0 ts=1970-01-01 00:00
   40k 2014/05/27 E:\util\cygwin\bin\cyggdbm-4.dll - os=4.0 img=0.0 sys=5.2
                  "cyggdbm-4.dll" v0.0 ts=1970-01-01 00:00
   13k 2014/05/27 E:\util\cygwin\bin\cyggdbm_compat-4.dll - os=4.0 img=0.0 sys=5.2
                  "cyggdbm_compat-4.dll" v0.0 ts=1970-01-01 00:00
  516k 2014/04/05 E:\util\cygwin\bin\cyggmp-10.dll - os=4.0 img=0.0 sys=5.2
                  "cyggmp-10.dll" v0.0 ts=1970-01-01 00:00
   46k 2014/06/01 E:\util\cygwin\bin\cyggomp-1.dll - os=4.0 img=0.0 sys=5.2
                  "cyggomp-1.dll" v0.0 ts=1970-01-01 00:00
  251k 2014/05/23 E:\util\cygwin\bin\cyggssapi_krb5-2.dll - os=4.0 img=0.0 sys=5.2
                  "cyggssapi_krb5-2.dll" v0.0 ts=1970-01-01 00:00
   29k 2013/03/14 E:\util\cygwin\bin\cyghistory7.dll - os=4.0 img=0.0 sys=5.2
                  "cyghistory7.dll" v0.0 ts=2013-03-14 11:14
  998k 2013/03/07 E:\util\cygwin\bin\cygiconv-2.dll - os=4.0 img=0.0 sys=5.2
                  "cygiconv-2.dll" v0.0 ts=2013-03-07 03:03
  195k 2013/04/05 E:\util\cygwin\bin\cygidn-11.dll - os=4.0 img=0.0 sys=5.2
                  "cygidn-11.dll" v0.0 ts=2013-04-05 09:58
   38k 2014/06/16 E:\util\cygwin\bin\cygintl-8.dll - os=4.0 img=0.0 sys=5.2
                  "cygintl-8.dll" v0.0 ts=1970-01-01 00:00
  294k 2013/09/09 E:\util\cygwin\bin\cygiodbc-2.dll - os=4.0 img=0.0 sys=5.2
                  "cygiodbc-2.dll" v0.0 ts=2013-09-09 16:36
   66k 2013/09/09 E:\util\cygwin\bin\cygiodbcinst-2.dll - os=4.0 img=0.0 sys=5.2
                  "cygiodbcinst-2.dll" v0.0 ts=2013-09-09 16:35
  888k 2013/05/05 E:\util\cygwin\bin\cygisl-10.dll - os=4.0 img=0.0 sys=5.2
                  "cygisl-10.dll" v0.0 ts=2013-05-05 16:36
  181k 2014/05/23 E:\util\cygwin\bin\cygk5crypto-3.dll - os=4.0 img=0.0 sys=5.2
                  "cygk5crypto-3.dll" v0.0 ts=1970-01-01 00:00
  700k 2014/05/23 E:\util\cygwin\bin\cygkrb5-3.dll - os=4.0 img=0.0 sys=5.2
                  "cygkrb5-3.dll" v0.0 ts=1970-01-01 00:00
   36k 2014/05/23 E:\util\cygwin\bin\cygkrb5support-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygkrb5support-0.dll" v0.0 ts=1970-01-01 00:00
   44k 2013/06/18 E:\util\cygwin\bin\cyglber-2-4-2.dll - os=4.0 img=0.0 sys=5.2
                  "cyglber-2-4-2.dll" v0.0 ts=2013-06-17 21:00
  243k 2013/06/18 E:\util\cygwin\bin\cygldap-2-4-2.dll - os=4.0 img=0.0 sys=5.2
                  "cygldap-2-4-2.dll" v0.0 ts=2013-06-17 21:00
  260k 2013/06/18 E:\util\cygwin\bin\cygldap_r-2-4-2.dll - os=4.0 img=0.0 sys=5.2
                  "cygldap_r-2-4-2.dll" v0.0 ts=2013-06-17 21:01
    6k 2014/08/13 E:\util\cygwin\bin\cyglsa64.dll - os=4.0 img=0.0 sys=5.2
                  "cyglsa64.dll" v0.0 ts=2014-08-13 22:05
  129k 2014/05/29 E:\util\cygwin\bin\cyglzma-5.dll - os=4.0 img=0.0 sys=5.2
                  "cyglzma-5.dll" v0.0 ts=1970-01-01 00:00
  106k 2014/07/01 E:\util\cygwin\bin\cygmagic-1.dll - os=4.0 img=0.0 sys=5.2
                  "cygmagic-1.dll" v0.0 ts=1970-01-01 00:00
  158k 2014/08/12 E:\util\cygwin\bin\cygman-2-6-7.dll - os=4.0 img=0.0 sys=5.2
                  "cygman-2-6-7.dll" v0.0 ts=1970-01-01 00:00
   30k 2014/05/26 E:\util\cygwin\bin\cygmenuw-10.dll - os=4.0 img=0.0 sys=5.2
                  "cygmenuw-10.dll" v0.0 ts=1970-01-01 00:00
   87k 2014/04/05 E:\util\cygwin\bin\cygmpc-3.dll - os=4.0 img=0.0 sys=5.2
                  "cygmpc-3.dll" v0.0 ts=1970-01-01 00:00
  319k 2013/05/05 E:\util\cygwin\bin\cygmpfr-4.dll - os=4.0 img=0.0 sys=5.2
                  "cygmpfr-4.dll" v0.0 ts=2013-05-05 13:40
 2833k 2013/12/06 E:\util\cygwin\bin\cygmysqlclient-18.dll - os=4.0 img=18.0 sys=5.2
                  "cygmysqlclient-18.dll" v0.0 ts=2013-12-06 01:49
   53k 2014/05/26 E:\util\cygwin\bin\cygncurses++w-10.dll - os=4.0 img=0.0 sys=5.2
                  "cygncurses++w-10.dll" v0.0 ts=1970-01-01 00:00
  299k 2014/05/26 E:\util\cygwin\bin\cygncursesw-10.dll - os=4.0 img=0.0 sys=5.2
                  "cygncursesw-10.dll" v0.0 ts=1970-01-01 00:00
  126k 2013/04/24 E:\util\cygwin\bin\cygneon-27.dll - os=4.0 img=0.0 sys=5.2
                  "cygneon-27.dll" v0.0 ts=2013-04-24 08:25
  207k 2014/03/13 E:\util\cygwin\bin\cygp11-kit-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygp11-kit-0.dll" v0.0 ts=2014-03-13 03:35
   15k 2014/05/26 E:\util\cygwin\bin\cygpanelw-10.dll - os=4.0 img=0.0 sys=5.2
                  "cygpanelw-10.dll" v0.0 ts=1970-01-01 00:00
  271k 2014/03/12 E:\util\cygwin\bin\cygpcre-1.dll - os=4.0 img=0.0 sys=5.2
                  "cygpcre-1.dll" v0.0 ts=2014-03-12 02:35
 1580k 2013/03/11 E:\util\cygwin\bin\cygperl5_14.dll - os=4.0 img=0.0 sys=5.2
                  "cygperl5_14.dll" v0.0 ts=2013-03-12 00:25
   38k 2014/05/12 E:\util\cygwin\bin\cygpipeline-1.dll - os=4.0 img=0.0 sys=5.2
                  "cygpipeline-1.dll" v0.0 ts=1970-01-01 00:00
   41k 2013/10/21 E:\util\cygwin\bin\cygpopt-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygpopt-0.dll" v0.0 ts=2013-10-21 21:52
  145k 2014/07/27 E:\util\cygwin\bin\cygpq-5.dll - os=4.0 img=0.0 sys=5.2
                  "cygpq-5.dll" v0.0 ts=1970-01-01 00:00
  122k 2013/04/21 E:\util\cygwin\bin\cygproxy-1.dll - os=4.0 img=1.0 sys=5.2
                  "cygproxy-1.dll" v0.0 ts=2013-04-21 10:24
  302k 2014/06/01 E:\util\cygwin\bin\cygquadmath-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygquadmath-0.dll" v0.0 ts=1970-01-01 00:00
  193k 2013/03/14 E:\util\cygwin\bin\cygreadline7.dll - os=4.0 img=0.0 sys=5.2
                  "cygreadline7.dll" v0.0 ts=2013-03-14 11:14
   97k 2014/05/26 E:\util\cygwin\bin\cygsasl2-3.dll - os=4.0 img=0.0 sys=5.2
                  "cygsasl2-3.dll" v0.0 ts=1970-01-01 00:00
   83k 2014/08/12 E:\util\cygwin\bin\cygserf-1-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygserf-1-0.dll" v0.0 ts=1970-01-01 00:00
  733k 2014/06/06 E:\util\cygwin\bin\cygsqlite3-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygsqlite3-0.dll" v0.0 ts=1970-01-01 00:00
  379k 2014/08/07 E:\util\cygwin\bin\cygssl-1.0.0.dll - os=4.0 img=0.0 sys=5.2
                  "cygssl-1.0.0.dll" v0.0 ts=1970-01-01 00:00
   11k 2014/06/01 E:\util\cygwin\bin\cygssp-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygssp-0.dll" v0.0 ts=1970-01-01 00:00
  892k 2014/06/01 E:\util\cygwin\bin\cygstdc++-6.dll - os=4.0 img=0.0 sys=5.2
                  "cygstdc++-6.dll" v0.0 ts=1970-01-01 00:00
  357k 2014/08/12 E:\util\cygwin\bin\cygsvn_client-1-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygsvn_client-1-0.dll" v0.0 ts=1970-01-01 00:00
   63k 2014/08/12 E:\util\cygwin\bin\cygsvn_delta-1-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygsvn_delta-1-0.dll" v0.0 ts=1970-01-01 00:00
   70k 2014/08/12 E:\util\cygwin\bin\cygsvn_diff-1-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygsvn_diff-1-0.dll" v0.0 ts=1970-01-01 00:00
   30k 2014/08/12 E:\util\cygwin\bin\cygsvn_fs-1-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygsvn_fs-1-0.dll" v0.0 ts=1970-01-01 00:00
  150k 2014/08/12 E:\util\cygwin\bin\cygsvn_fs_base-1-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygsvn_fs_base-1-0.dll" v0.0 ts=1970-01-01 00:00
  180k 2014/08/12 E:\util\cygwin\bin\cygsvn_fs_fs-1-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygsvn_fs_fs-1-0.dll" v0.0 ts=1970-01-01 00:00
   10k 2014/08/12 E:\util\cygwin\bin\cygsvn_fs_util-1-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygsvn_fs_util-1-0.dll" v0.0 ts=1970-01-01 00:00
   45k 2014/08/12 E:\util\cygwin\bin\cygsvn_ra-1-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygsvn_ra-1-0.dll" v0.0 ts=1970-01-01 00:00
   30k 2014/08/12 E:\util\cygwin\bin\cygsvn_ra_local-1-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygsvn_ra_local-1-0.dll" v0.0 ts=1970-01-01 00:00
  164k 2014/08/12 E:\util\cygwin\bin\cygsvn_ra_serf-1-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygsvn_ra_serf-1-0.dll" v0.0 ts=1970-01-01 00:00
   94k 2014/08/12 E:\util\cygwin\bin\cygsvn_ra_svn-1-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygsvn_ra_svn-1-0.dll" v0.0 ts=1970-01-01 00:00
  182k 2014/08/12 E:\util\cygwin\bin\cygsvn_repos-1-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygsvn_repos-1-0.dll" v0.0 ts=1970-01-01 00:00
  380k 2014/08/12 E:\util\cygwin\bin\cygsvn_subr-1-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygsvn_subr-1-0.dll" v0.0 ts=1970-01-01 00:00
  621k 2014/08/12 E:\util\cygwin\bin\cygsvn_wc-1-0.dll - os=4.0 img=0.0 sys=5.2
                  "cygsvn_wc-1-0.dll" v0.0 ts=1970-01-01 00:00
   69k 2013/04/22 E:\util\cygwin\bin\cygtasn1-6.dll - os=4.0 img=0.0 sys=5.2
                  "cygtasn1-6.dll" v0.0 ts=2013-04-22 01:25
   53k 2014/05/26 E:\util\cygwin\bin\cygticw-10.dll - os=4.0 img=0.0 sys=5.2
                  "cygticw-10.dll" v0.0 ts=1970-01-01 00:00
   14k 2014/07/09 E:\util\cygwin\bin\cyguuid-1.dll - os=4.0 img=0.0 sys=5.2
                  "cyguuid-1.dll" v0.0 ts=1970-01-01 00:00
   79k 2013/05/09 E:\util\cygwin\bin\cygz.dll - os=4.0 img=0.0 sys=5.2
                  "cygz.dll" v0.0 ts=2013-05-09 22:20
 3083k 2014/08/13 E:\util\cygwin\bin\cygwin1.dll - os=4.0 img=0.0 sys=5.2
                  "cygwin1.dll" v0.0 ts=1970-01-01 00:00
    Cygwin DLL version info:
        DLL version: 1.7.32
        DLL epoch: 19
        DLL old termios: 5
        DLL malloc env: 28
        Cygwin conv: 181
        API major: 0
        API minor: 274
        Shared data: 5
        DLL identifier: cygwin1
        Mount registry: 3
        Cygwin registry name: Cygwin
        Program options name: Program Options
        Installations name: Installations
        Cygdrive default prefix: 
        Build date: 
        Shared id: cygwin1S5


Can't find the cygrunsrv utility, skipping services check.


Cygwin Package Information
Last downloaded files to: e:\inst\util\cygwin
Last downloaded files from: http://box-soft.com/

Package                  Version            Status
_autorebase              000197-1           OK
_update-info-dir         00304-1            OK
alternatives             1.3.30c-10         OK
base-cygwin              3.3-1              OK
base-files               4.2-3              OK
bash                     4.1.11-2           OK
binutils                 2.24.51-5          OK
bzip2                    1.0.6-2            OK
ca-certificates          1.97-2             OK
coreutils                8.23-2             OK
crypt                    1.1-1              OK
cygutils                 1.4.14-1           OK
cygwin                   1.7.32-1           OK
cygwin-doc               1.7-1              OK
dash                     0.5.7-4            OK
editrights               1.02-1             OK
expect                   5.45-2             OK
file                     5.19-1             OK
findutils                4.5.12-1           OK
gawk                     4.1.1-1            OK
gcc-core                 4.8.3-2            OK
gcc-g++                  4.8.3-2            OK
gdb                      7.8-1              OK
getent                   2.18.90-2          OK
grep                     2.16-1             OK
groff                    1.22.2-2           OK
gzip                     1.4-1              OK
hostname                 3.13-1             OK
ipc-utils                1.0-2              OK
less                     458-1              OK
libapr1                  1.4.8-1            OK
libaprutil1              1.5.2-4            OK
libargp                  20110921-2         OK
libatomic1               4.8.3-2            OK
libattr1                 2.4.46-1           OK
libblkid1                2.24.2-1           OK
libbz2_1                 1.0.6-2            OK
libcloog-isl4            0.18.0-2           OK
libcom_err2              1.42.10-1          OK
libcrypt0                1.1-1              OK
libdb5.3                 5.3.21-1           OK
libexpat1                2.1.0-3            OK
libffi6                  3.0.13-1           OK
libgcc1                  4.8.3-2            OK
libgdbm4                 1.11-1             OK
libgmp10                 6.0.0a-1           OK
libgomp1                 4.8.3-2            OK
libgssapi_krb5_2         1.12.1-2           OK
libiconv2                1.14-1             OK
libidn11                 1.26-1             OK
libintl8                 0.18.3.2-2         OK
libiodbc2                3.52.8-2           OK
libisl10                 0.11.1-2           OK
libk5crypto3             1.12.1-2           OK
libkrb5_3                1.12.1-2           OK
libkrb5support0          1.12.1-2           OK
liblzma5                 5.0.5-1            OK
libmpc3                  1.0.2-1            OK
libmpfr4                 3.1.2-1            OK
libmysqlclient18         5.5.35-1           OK
libncursesw10            5.9-20140524-1     OK
libneon27                0.29.6-1           OK
libopenldap2_4_2         2.4.35-1           OK
libopenssl100            1.0.1i-1           OK
libp11-kit0              0.20.2-1           OK
libpcre1                 8.34-1             OK
libpipeline1             1.3.0-3            OK
Empty package libpopt0
libpopt0                 1.16-1             OK
libpq5                   9.3.5-1            OK
libproxy1                0.4.11-2           OK
libquadmath0             4.8.3-2            OK
libreadline7             6.2-1              OK
libsasl2_3               2.1.26-7           OK
libserf1_0               1.3.7-1            OK
libsqlite3_0             3.8.5-1            OK
libssp0                  4.8.3-2            OK
libstdc++6               4.8.3-2            OK
libtasn1_6               3.3-1              OK
libuuid1                 2.24.2-1           OK
login                    1.10-10            OK
lynx                     2.8.7-2            OK
make                     4.0-2              OK
man-db                   2.6.7-2            OK
mintty                   1.2-beta1-1        OK
openssl                  1.0.1i-1           OK
p11-kit                  0.20.2-1           OK
p11-kit-trust            0.20.2-1           OK
perl                     5.14.4-1           OK
popt                     1.16-1             OK
python                   2.7.8-1            OK
rebase                   4.4.1-1            OK
run                      1.3.1-1            OK
sed                      4.2.2-3            OK
subversion               1.8.10-1           OK
tar                      1.27.1-1           OK
tcl                      8.5.11-1           OK
terminfo                 5.9-20140524-1     OK
texinfo                  5.2-1              OK
tzcode                   2013c-1            OK
unzip                    6.0-1              OK
util-linux               2.24.2-1           OK
vim-minimal              7.4.335-1          OK
w32api-headers           3.1.0-2            OK
w32api-runtime           3.1.0-1            OK
which                    2.20-2             OK
whois                    5.0.26-1           OK
windows-default-manifest 6.3-1              OK
xz                       5.0.5-1            OK
zip                      3.0-12             OK
zlib0                    1.2.8-1            OK
Use -h to see help about each section


--
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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Bash uses lseek while reading from serial device
  2014-08-16 18:47 Bash uses lseek while reading from serial device Ross Ridge
@ 2014-08-17 22:19 ` Linda Walsh
  2014-08-18 11:21   ` Corinna Vinschen
  0 siblings, 1 reply; 5+ messages in thread
From: Linda Walsh @ 2014-08-17 22:19 UTC (permalink / raw)
  To: cygwin

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.3050509@tlinx.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@case.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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Bash uses lseek while reading from serial device
  2014-08-17 22:19 ` Linda Walsh
@ 2014-08-18 11:21   ` Corinna Vinschen
  0 siblings, 0 replies; 5+ messages in thread
From: Corinna Vinschen @ 2014-08-18 11:21 UTC (permalink / raw)
  To: cygwin; +Cc: Ross Ridge

[-- Attachment #1: Type: text/plain, Size: 872 bytes --]

On Aug 17 15:19, Linda Walsh wrote:
> 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...

On Linux isatty on a descriptor connected to serial line returns 0,
on Cygwin it returned 1 so far.  I fixed both problems here, isatty
on a serial line returns 0 now, and lseek on serial (and, FWIW,
sockets) don't simply return 0 anymore, but rather -1 with errno set
to ESPIPE, as on Linux.

These patches are available in the latest snapshot I just uploaded
to https://cygwin.com/snapshots/

Ross, please give it a try.


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Bash uses lseek while reading from serial device
  2014-08-19  2:40 Ross Ridge
@ 2014-08-19  8:35 ` Corinna Vinschen
  0 siblings, 0 replies; 5+ messages in thread
From: Corinna Vinschen @ 2014-08-19  8:35 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 1818 bytes --]

On Aug 18 22:39, Ross Ridge wrote:
> Corinna Vinschen writes:
> > On Linux isatty on a descriptor connected to serial line returns 0,
> > on Cygwin it returned 1 so far.  I fixed both problems here, isatty
> > on a serial line returns 0 now, and lseek on serial (and, FWIW,
> > sockets) don't simply return 0 anymore, but rather -1 with errno set
> > to ESPIPE, as on Linux.
> 
> I'm not sure if Chet Ramey's suggestion that if isatty() returns 1
> then bash is allowed to assume reads are newline-delimited is correct.
> On Unix this would only be true if cannonical mode input processing was
> enabled (icanon), and Cygwin stty reports that this mode is disabled
> (-icanon) on serial devices.  Or at least it used to, with the snapshot
> DLL it now complains "/dev/ttyS0: Inappropriate ioctl for device".
> 
> For what its worth my tests on Linux shows that isatty() returns 1 on
> a serial device, namely /dev/ttyS0.  Which is what I would expect given
> that serial devices have traditionally been synonymous with ttys on Unix.

I reverted this part of the patch.  My test was flawed.  The problem is
that on Linux, /dev/ttyS[0-3] exists even if they are not backed by
hardware.  In this case, as is on my local machine, isatty returns 0.
However, if there's a device connected to /dev/ttySx, isatty returns 1.

So I just applied a patch which reverts the isatty status to /dev/ttySx
and thus, stty works as before.

> > Ross, please give it a try.
> 
> The snapshot DLL solves the bug and the script runs without any data
> being lost.  Thanks for looking into this.

Thanks for testing and discussing this problem.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Bash uses lseek while reading from serial device
@ 2014-08-19  2:40 Ross Ridge
  2014-08-19  8:35 ` Corinna Vinschen
  0 siblings, 1 reply; 5+ messages in thread
From: Ross Ridge @ 2014-08-19  2:40 UTC (permalink / raw)
  To: cygwin

Corinna Vinschen writes:
> On Linux isatty on a descriptor connected to serial line returns 0,
> on Cygwin it returned 1 so far.  I fixed both problems here, isatty
> on a serial line returns 0 now, and lseek on serial (and, FWIW,
> sockets) don't simply return 0 anymore, but rather -1 with errno set
> to ESPIPE, as on Linux.

I'm not sure if Chet Ramey's suggestion that if isatty() returns 1
then bash is allowed to assume reads are newline-delimited is correct.
On Unix this would only be true if cannonical mode input processing was
enabled (icanon), and Cygwin stty reports that this mode is disabled
(-icanon) on serial devices.  Or at least it used to, with the snapshot
DLL it now complains "/dev/ttyS0: Inappropriate ioctl for device".

For what its worth my tests on Linux shows that isatty() returns 1 on
a serial device, namely /dev/ttyS0.  Which is what I would expect given
that serial devices have traditionally been synonymous with ttys on Unix.

> Ross, please give it a try.

The snapshot DLL solves the bug and the script runs without any data
being lost.  Thanks for looking into this.

					Ross Ridge


--
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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-08-19  8:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-16 18:47 Bash uses lseek while reading from serial device Ross Ridge
2014-08-17 22:19 ` Linda Walsh
2014-08-18 11:21   ` Corinna Vinschen
2014-08-19  2:40 Ross Ridge
2014-08-19  8:35 ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).