mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Reuse the argv[0] string in program_invocation_name(3).
This commit is contained in:
parent
392472af5c
commit
8fef8f7bb1
1 changed files with 1 additions and 10 deletions
|
@ -43,22 +43,13 @@ static char* find_last_elem(char* str)
|
|||
|
||||
extern "C" void initialize_standard_library(int argc, char* argv[])
|
||||
{
|
||||
// We got ourselves a little bootstrap problem. We'd like these variables to
|
||||
// be available during early startup - however, we can't create a copy yet
|
||||
// because the heap isn't initialized yet. Instead, we'll simply point at
|
||||
// the original value - we're safe since argv[0] is not supposed to be
|
||||
// modified until main is run. Once we heap is up, we'll strdup.
|
||||
const char* argv0 = argc ? argv[0] : "";
|
||||
program_invocation_name = (char*) argv0;
|
||||
program_invocation_short_name = find_last_elem((char*) argv0);
|
||||
|
||||
// Initialize pthreads and stuff like thread-local storage.
|
||||
// Initialize pthreads.
|
||||
pthread_initialize();
|
||||
|
||||
// Initialize stdio.
|
||||
init_stdio();
|
||||
|
||||
// We can now create a copy of the program name variables safely.
|
||||
program_invocation_name = strdup(program_invocation_name);
|
||||
program_invocation_short_name = find_last_elem(program_invocation_name);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue