Low-level string output.
Low-level string output.This function has exactly the same syntax and semantics as write(). The reason for its existence is complex: if non-blocking I/O is used, excessive output may overrun the OS output buffer. Under Linux, this is 4 kbytes, a fact that can account for long listings getting garbled. So we loop, trying to write as much of the string as we can, waiting a bit between writes --- but only if the entire string couldn't be sent. The performance impact should be minimal, as the bottleneck is likely to be the user's bandwidth anyway.
The trick is to wait for the output buffer to have some more space, unless of course we've managed to send the whole string in the first attempt. This depends on bandwidth. It doesn't need to be big for the Linux console. Modems can't send out information as fast, so we have to wait more. To cover all cases, we wait for a pretty long time. This might produce slightly jerky output on the console (though I personally can't detect it), but won't easily be detectable on a modem.
I really want to do away with this horror. It's a great big kludge and it stinks, and I hate it. Please, please, tell me there's a nice, elegant, standard way to either flush the output buffer and wait till it's empty, or to get a measure of how full the output buffer is.