summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2001-02-19 10:33:52 +0000
committerManuel Novoa III <mjn3@codepoet.org>2001-02-19 10:33:52 +0000
commit84fb6c9e25ba15319b817ecf2a46e2cb83d64d13 (patch)
tree6258a9d37ef5bced61757db7ee2b36bc767cf605 /libc
parentd959f3d79c28fe6cf1ab2ed63e60cb1152130c55 (diff)
Make sure errno is 0 before we call main (may have been set while initializing).
Diffstat (limited to 'libc')
-rw-r--r--libc/misc/internals/__uClibc_main.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c
index 088754ecc..827d82e5f 100644
--- a/libc/misc/internals/__uClibc_main.c
+++ b/libc/misc/internals/__uClibc_main.c
@@ -12,6 +12,7 @@
#include <stdlib.h>
#include <unistd.h>
+#include <errno.h>
/*
* Prototypes.
@@ -62,6 +63,13 @@ void __uClibc_main(int argc, char **argv, char **envp)
__init_stdio();
/*
+ * Note: It is possible that any initialization done above could
+ * have resulted in errno being set nonzero, so set it to 0 before
+ * we call main.
+ */
+ errno = 0;
+
+ /*
* Finally, invoke application's main and then exit.
*/
exit(main(argc, argv, envp));
@@ -69,6 +77,8 @@ void __uClibc_main(int argc, char **argv, char **envp)
/*
* Declare the __environ global variable and create a weak alias environ.
+ * Note: Apparently we must initialize __environ for the weak environ
+ * symbol to be included.
*/
char **__environ = 0;