Hi

While investigating this, I stumbled upon another bug:

#include <unistd.h>
#include <stdio.h>

int main() {
        FILE *fstream;
        int len;

        fclose(stdout);

        len=printf("test this\n");

        fprintf(stderr,"%d\n",len);

        return 0;
}

Musl's printf gives the amount of bytes no matter whether it succeeds or fails.
It should return a negative value in case of failure.

Regards
Paul

On Wed, Oct 24, 2012 at 9:36 PM, Paul Schutte <sjpschutte@gmail.com> wrote:
Hi

I compiled and linked libwebserver-0.5.3 against musl.

It would just strangely break halfway through a request. After hours of searching, I found the problem.

I can demonstrate it with the following code:

#include <unistd.h>
#include <stdio.h>

int main() {
    FILE *fstream;

    fclose(stdout);

    fstream=freopen("/dev/tty","w",stdout);

    if (fstream==NULL) {
        fprintf(stderr,"freopen failed\n");
    }

    printf("test this\n");
   

    return 0;
}

This snippet works fine when using glibc.

Regards
Paul