The behaviour is not defined; musl loses parts of long data lines. Change code to work with file descriptors directly and handle buffering ourselves.