1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Retrieve init process id from INIT_PID environmental variable.

This commit is contained in:
Jonas 'Sortie' Termansen 2013-06-15 16:28:33 +02:00
parent f8f65d5713
commit 6ea41cc620

View file

@ -326,7 +326,13 @@ int get_and_run_command(FILE* fp, const char* fpname, bool interactive,
*exitexec = true;
return status;
}
if ( getppid() == 1 )
const char* init_pid_str = getenv("INIT_PID");
if ( !init_pid_str)
init_pid_str = "1";
pid_t init_pid = (pid_t) atol(init_pid_str);
if ( !init_pid )
init_pid = 1;
if ( getppid() == init_pid )
{
printf("\nType exit to shutdown the system.\n");
return status;