home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!news.funet.fi!hydra!klaava!torvalds
- From: torvalds@klaava.Helsinki.FI (Linus Benedict Torvalds)
- Newsgroups: comp.os.linux
- Subject: Re: Termios question: Semantics of VMIN/VTIME on Linux/SunOS ?
- Message-ID: <1992Jul19.201601.13942@klaava.Helsinki.FI>
- Date: 19 Jul 92 20:16:01 GMT
- References: <9207151400@gandalf.moria> <arumble.711530378@extro.ucc.su.OZ.AU>
- Organization: University of Helsinki
- Lines: 39
-
- In article <arumble.711530378@extro.ucc.su.OZ.AU> arumble@extro.ucc.su.OZ.AU (Anthony Rumble) writes:
- >michael@gandalf.moria (Michael Haardt) writes:
- >
- >> buff.c_cc[VMIN]=5;
- >> buff.c_cc[VTIME]=1;
- >> tcsetattr(file,TCSANOW,&buff);
- >
- >>I am no termios expert, but this code is intended to let a
- >
- >> read(file,buffer,sizeof(buffer));
- >>
- >>read as much characters as available, max sizeof(buffer) and return
- >>after a short timeout if there are none. Ok?
-
- The way linux does this is (a) wait for at least one character (VMIN > 0
- and VTIME > 0), (b) read as many characters as possible, with a timeout
- of max 0.10 seconds between any of the first 5 characters. Thus the
- read can return:
-
- -1:
- EINTR - a signal happened (but you usually don't see this: the
- read is mostly re-tried after the signal is handled)
-
- 1-5:
- linux got one character, followed by four characters within the
- inter-character timeout given (VTIME = 1 -> 0.1 sec).
-
- 6-sizeof(buffer):
- after the fifth character there was actually more data
- available, without any timeout.
-
- >I was under the impression that this should actually return on
- >either 5 characters recieved, or sizeof(buffer), or timeout..
-
- The only thing that I have that explains this all is the SunOS manpage,
- so I cannot actually guarantee the above behaviour by linux is correct.
- Could somebody with the POSIX standard available actually check it out?
-
- Linus
-