Read and write /dev/ttya?

Andrew G. Minter agm at stl.stc.co.uk
Wed Jan 23 21:07:32 AEST 1991


In the referenced article veit at du9ds3.uni-duisburg.de (Holger Veit) writes:
>montnaro at spyder.crd.ge.com (Skip Montanaro) writes:
>>The getc() just hangs. What am I doing wrong?
>stdio does input and output buffering. If your answering device does not
>deliver a Carriage return as a block limiter, your getc() call will wait
>forever. Try including 
>	setbuf(f,NULL);	

This surely depends on where the buffering is done.  Most UNIX systems will,
by default, do line buffering on tty input in the kernel.  You may find it
necessary to put the tty into CBREAK or RAW mode using an ioctl code.  I
have a deep mistrust of stdio.  It seems that the "tricky bits" work
*slightly* different on every UNIX box I come to and it's very hard to write
portable code.  It may be a better idea to keep to low level I/O when
talking to a device.

Andrew



More information about the Comp.unix.programmer mailing list