"The process tried to write to a nonexistent pipe"
EDIT: I figured out my problem thanks to the magic of posting about it. My program was ending when it detected a log file entry that was after the date range it was supposed to be converting. If the log contained a large amount of data after this, the type command would print the error when it tried to write to my program, which had ended.
ORIGINAL POST:
I've written a program that converts a proprietary log file to HTML. It reads from standard input and writes to standard output. It's used by piping the log file to it with type or cat, and then redirecting the output to a file.
A couple people are using it successfully, but one user is having problems when his log files get too large. He gets this error: "The process tried to write to a nonexistent pipe"
I think what's happening is my program is prematurely detecting the end of the file and exiting. My program just reads from stdin until read returns -1.
Code:
while(true) {
int read = System.in.read(buffer);
if(read == -1) break;
Record record = new Record(buffer, 0);
Date ts = record.getDate();
if(ts.after(begin) || ts.equals(begin)) {
if(ts.before(end)) {
records.add(record);
}
else break;
}
}
Could the problem be caused by a limited buffer size in the shell's pipe or a delay in writing to it? Would that cause read to return -1?
Is there anything I can do, short of changing my program to read the file directly instead of reading from stdin?