aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorseyko <seyko2@gmail.com>2015-03-25 13:26:11 +0300
committerseyko <seyko2@gmail.com>2015-03-25 13:26:11 +0300
commitcde79a805e673b21bd2aa2fc916975f423f8ccf6 (patch)
treefd3c6e56ddef6370f5c9dad25a5500c58918b724
parent724425addf52e16e8410730d52617311f14c9cfc (diff)
downloadtinycc-cde79a805e673b21bd2aa2fc916975f423f8ccf6.tar.gz
tinycc-cde79a805e673b21bd2aa2fc916975f423f8ccf6.tar.bz2
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; }
-rw-r--r--tccrun.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/tccrun.c b/tccrun.c
index 8f7257d..8e53a70 100644
--- a/tccrun.c
+++ b/tccrun.c
@@ -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;
}