MFC: r268997

For "a"-mode files and rewind/fseek + fwrite combination return meaningful
value now, like Apple does, but avoid their __sflush physical write
performance degradation as much as possible.
MFC: r269116

In the "Too many open files" edge cases don't try to preserve old
number for non-std* descriptors, but close old file and retry.

Obtained from:  inspired by Apple's change from pfg@