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:
parent
724425addf
commit
cde79a805e
1 changed files with 4 additions and 0 deletions
4
tccrun.c
4
tccrun.c
|
@ -127,6 +127,7 @@ LIBTCCAPI int tcc_run(TCCState *s1, int argc, char **argv)
|
||||||
for (i=0; i<argc; ++i)
|
for (i=0; i<argc; ++i)
|
||||||
bound_new_region(argv[i], strlen(argv[i]));
|
bound_new_region(argv[i], strlen(argv[i]));
|
||||||
|
|
||||||
|
errno = 0; /* clean errno value */
|
||||||
ret = (*prog_main)(argc, argv);
|
ret = (*prog_main)(argc, argv);
|
||||||
|
|
||||||
/* unmark argv area */
|
/* unmark argv area */
|
||||||
|
@ -137,7 +138,10 @@ LIBTCCAPI int tcc_run(TCCState *s1, int argc, char **argv)
|
||||||
bound_exit();
|
bound_exit();
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
errno = 0; /* clean errno value */
|
||||||
ret = (*prog_main)(argc, argv);
|
ret = (*prog_main)(argc, argv);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue