From 6ea41cc620aab7060b73064419d0e359816b5a60 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sat, 15 Jun 2013 16:28:33 +0200 Subject: [PATCH] Retrieve init process id from INIT_PID environmental variable. --- utils/mxsh.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/utils/mxsh.cpp b/utils/mxsh.cpp index 739bc69f..95187164 100644 --- a/utils/mxsh.cpp +++ b/utils/mxsh.cpp @@ -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;