LibC: Pass the environment as third argument to main()

After some very confused debugging, I discovered that GNU make has a
main() function with this signature:

    int main(int argc, char** argv, char** envp)

Apparently this is a non-standard but widely supported thing, so let's
do the same in Serenity so make works as expected.

This fixes an issue where you had to do "make PATH=..." instead of make
just picking up PATH from the environment. :^)
This commit is contained in:
Andreas Kling 2019-09-12 21:43:32 +02:00
parent 27321e9c44
commit c74e4d0c80
Notes: sideshowbarker 2024-07-19 12:08:53 +09:00

View File

@ -4,7 +4,7 @@
extern "C" {
int main(int, char**);
int main(int, char**, char**);
__thread int errno;
char** environ;
@ -36,7 +36,7 @@ int _start(int argc, char** argv, char** env)
for (size_t i = 0; i < size; i++)
(*__init_array_start[i])(argc, argv, env);
int status = main(argc, argv);
int status = main(argc, argv, environ);
exit(status);