Rename the init process inside PID namespaces.
Rename the init process that Minijail launches inside PID namespaces.
This makes it easier to identify things when looking at 'ps' output.
Bug: 30789126
Change-Id: Iffe3ea1fc2ecb66b1bae96912e2664913ca00d75
diff --git a/libminijail.c b/libminijail.c
index cb03d5e..0ba5f01 100644
--- a/libminijail.c
+++ b/libminijail.c
@@ -1538,7 +1538,7 @@
_exit(init_exitstatus);
}
-int init(pid_t rootpid)
+void init(pid_t rootpid)
{
pid_t pid;
int status;
@@ -2012,10 +2012,13 @@
* WARNING above.
*/
child_pid = fork();
- if (child_pid < 0)
+ if (child_pid < 0) {
_exit(child_pid);
- else if (child_pid > 0)
- init(child_pid); /* never returns */
+ } else if (child_pid > 0) {
+ /* Best effort. Don't bother checking the return value. */
+ prctl(PR_SET_NAME, "minijail-init");
+ init(child_pid); /* Never returns. */
+ }
}
/*