fix a bug #43984: tcc -run reports errno=2

The following program (errno.c) reports errno=2 when run
    using "tcc -run errno.c"

    #include <errno.h>
    #include <stdio.h>
    int main(void) { printf("errno=%d\n", errno); return 0; }
This commit is contained in:
seyko 2015-03-25 13:26:11 +03:00
parent 724425addf
commit cde79a805e

View File

@ -127,6 +127,7 @@ LIBTCCAPI int tcc_run(TCCState *s1, int argc, char **argv)
for (i=0; i<argc; ++i)
bound_new_region(argv[i], strlen(argv[i]));
errno = 0; /* clean errno value */
ret = (*prog_main)(argc, argv);
/* unmark argv area */
@ -137,7 +138,10 @@ LIBTCCAPI int tcc_run(TCCState *s1, int argc, char **argv)
bound_exit();
} else
#endif
{
errno = 0; /* clean errno value */
ret = (*prog_main)(argc, argv);
}
return ret;
}