julian@acp.OZ (Julian Elischer) (10/02/87)
Reading the unix system V.2 and V.3 manuals, I see that if ICANON is not set then a read will return an TIME 10ths of a second or when MIN characters are available. I cannot however see how to get it to sit indefinitly and wait for a character. Is this feature (timeouts) only available if the O_NDELAY flag is set in the file or is it always operational. Is this feature used widely? Does anybody know of documentation that is clear on this point? It is quite possible that the information I seek is actually somewhere in the 3b2 sysV manuals I have, but you have to know what's in them already if you want to find anything which is a bit of a pain. (for instance to find out how to stop fork/exit from creating zombies, you have to look under SIGNAL of all places!)(flame off) Several items I would like to find out are: 1/ what is the exact configuration of termio needed give the standard RAW mode under sysV. 2/ is there a similar timeout facility available for pipes or do i HAVE to use ALARM/SIGNAL etc? 3/ is there any clearer description of SYSV.3 shared memory/ massages/semaphore operations than the hopeless ATT "Documentation".. something that describes the whole thing in a useable way instead of drowning you in details. 4/ does a value of 255 or something disable the TIMEOUT in the affore mentioned TERMIO ~ICANON mode ? or does it have to be enabled by some hidden switch?? do I have to loop every 25.5 seconds? When I run programs trying this, they seem to just wait. (c_cc[5] = 0) how do I then get it to come back straight away? This is how I see it at the moment.. could someone give me some idea what REALLY HAPPENS? if you want immediate return, use the O_NDELAY flag with fcntl() if you want to wait indefinitly, use c_cc[5] = 0 in ioclt with O_NDELAY not active. if you want n 10ths timeout, use c_cc[5] = n in ioctl() with O_DELAY inactive. is this right? thanks for any replies from those ahead of myself. replies from thos not ahead will be laughed at according to merrit 8-). replies by mail please: julian elischer uucp: {lots of places }!munnari!acp.oz!julian ACSnet (that's within australia to those out there in usa land ): julian@acp.oz
guy%gorodish@Sun.COM (Guy Harris) (10/06/87)
> Reading the unix system V.2 and V.3 manuals, I see that > if ICANON is not set then a read will return an TIME 10ths > of a second or when MIN characters are available. > I cannot however see how to get it to sit indefinitly > and wait for a character. Is this feature (timeouts) only > available if the O_NDELAY flag is set in the file or > is it always operational. It is always operational (as long as ICANON is not set). > Is this feature used widely? I don't know. There are really two separate timeout features: 1) If MIN is non-zero, the timer is (re)started every time a character arrives; if the timer expires before a character arrives, the processes waiting on a "read" are woken up and a "read" will complete. If TIME is zero, there is no timer, and no timeout will occur. 2) If MIN is zero, the timer is started when the "read" is done; if the timer expires before a character arrives, the processes waiting on a "read" are woken up and a "read" will complete, returning 0 bytes. If TIME is zero, there is no timer, and the read will always terminate immediately - in effect, this is an alternate form of no-delay read. The second timeout feature was not present in System III; my suspicion is that somebody thought it should have been, and changed the tty driver in System V to add it. Given that it wasn't in System III, and given that you can implement timeouts of 1 second or greater using "alarm", I have no idea who actually uses it. > Does anybody know of documentation that is clear on > this point? It depends on your definition of "clear". The SVID has a long section describing the way MIN and TIME work; I believe it was derived from the description in a POSIX draft (I think the POSIX description antedated the SVID description, but it may have been the other way around). As such, it reads like a standard, rather than like a tutorial. All the information is there, it may just be hard to retrieve. > (for instance to find out how to stop fork/exit from creating zombies, > you have to look under SIGNAL of all places!)(flame off) It makes sense to put it there, as long as you grant that it makes sense to implement this feature with the "signal" system call; the latter is the problem. Overloading the meaning of SIG_IGN in that fashion is a bit tacky. > Several items I would like to find out are: > 1/ what is the exact configuration of termio needed > give the standard RAW mode under sysV. Turn IGNBRK, BRKINT, IGNPAR, PARMRK, INPCK, ISTRIP, INLCR, IGNCR, ICRNL, IUCLC, and IXON off in the "c_iflag" field. Turn OPOST off in the "c_oflag" field. Set the CSIZE subfield of the "c_cflag" field to CS8, and turn off PARENB. Turn off ISIG, ICANON, and XCASE in the "c_lflag" field. Set c_cc[VMIN] to 1, and c_cc[VTIME] to 0. (You can try other settings of MIN and TIME, as long as MIN is non-zero; a larger VMIN can increase the chances of getting more than one character per "read", and thus decrease the number of "read" calls issued.) > 2/ is there a similar timeout facility available > for pipes or do i HAVE to use ALARM/SIGNAL etc? You have to use "alarm"/"signal". > 4/ does a value of 255 or something disable the TIMEOUT in the > affore mentioned TERMIO ~ICANON mode ? No, a value of 0 does. See above. > This is how I see it at the moment.. could someone give me > some idea what REALLY HAPPENS? > if you want immediate return, use the O_NDELAY flag with fcntl() or a MIN and TIME of 0 (please don't say "c_cc[5]", say "c_cc[VTIME]" or just "TIME"; most of us haven't memorized the indices in "c_cc"). > if you want to wait indefinitly, use c_cc[5] = 0 in ioclt with > O_NDELAY not active. As long as MIN is non-zero; if MIN is zero, as well as TIME, you will get an immediate return. > if you want n 10ths timeout, use c_cc[5] = n in ioctl() with > O_DELAY inactive. Yes, depending on the sort of timeout you want. The value of MIN selects the type of timeout. Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com
latham@ablnc.ATT.COM (Ken Latham) (10/07/87)
In article <403@acp.OZ>, julian@acp.OZ (Julian Elischer) writes: > Reading the unix system V.2 and V.3 manuals, I see that > if ICANON is not set then a read will return an TIME 10ths > of a second or when MIN characters are available. > I cannot however see how to get it to sit indefinitly > and wait for a character. ..... > 1/ what is the exact configuration of termio needed > give the standard RAW mode under sysV. ICANON off Standard RAW ????? no such beastie :-> MIN 1 TIMEOUT 0 > 2/ is there a similar timeout facility available > for pipes or do i HAVE to use ALARM/SIGNAL etc? use Alarm/Signal this is much more portable. > 3/ is there any clearer description of SYSV.3 shared memory/ > massages/semaphore operations than the hopeless ATT > "Documentation".. something that describes the whole > thing in a useable way instead of drowning you in details. I assume the "documentation you are refering to is the standard manual set, yes this is just facts to guide the experienced user. The "AT&T :-) System V Interprocess Communications Guide" is what you want it gives examples and explains the ordinary use of queues, shared memory and semaphores. > 4/ does a value of 255 or something disable the TIMEOUT in the > affore mentioned TERMIO ~ICANON mode ? see above Ken Latham AT&T Support ..!ihnp4!ablnc!latham