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
1 changed files with 7 additions and 1 deletions

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;