Lost characters and missing characters
Robin Cutshaw
robin at itcatl.UUCP
Thu Oct 23 01:50:48 AEST 1986
Problem 1:
char buf[BUFSIZ];
int fdi, fdo, count;
nice(-40); /* -20 is max but... */
if ((fdi = open(COMDEV, O_RDWR)) >= 0) {
/* set baud to 9600, flags to ANYP | CBREAK, maybe TANDEM */
if ((fdo = open(OUTFILE, O_RDWR)) >= 0)
while ((count = read(fdi, buf, BUFSIZ)) > 0)
if (write(fdo, buf, count) != count)
process_write_error();
}
At 9600 baud on the COMDEV this process looses characters periodically.
If however, I use tip to connect to the COMDEV all characters will be
transmitted correctly. Why am I losing characters and tip isn't?
When I lose characters, it is typically 256 at a time.
Problem 2:
open input and output regular files
while (1) {
if ((curpos = lseek(fdi, 0, L_INCR)) < 0) /* where are we */
process_lseek_error();
if ((eofpos = lseek(fdi, 0, L_XTND)) < 0) /* where's the end */
process_lseek_error();
if ((charstoread = (eofpos - curpos)) > 0) {
if ((lseek(fdi, curpos, L_SET)) < 0) /* set back */
process_lseek_error();
if ((count = read(fdi, buf, charstoread)) <= 0)
process_read_error(count);
process_chars(buf,count);
}
}
The input file is constantly growing. It always happens that
somewhere between 1 and 2 K into the file the variable charstoread
is between 20 and 50 and when the read occurs it returns 0.
When can their be characters between your current position and the
end of file, and read return end of file?
robin cutshaw {akgua,gatech}!itcatl!robin
More information about the Comp.unix.wizards
mailing list