Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 0611644

Browse files
author
Damien Lespiau
committed
init: Only do the init process setup if launched as "init"
We base this detection on the name of the binary: "init" means we've been started as an init system. When not running as an init system, we can skip the basic initialisation as systemd or any other init system would have done that for us. Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
1 parent bfc5002 commit 0611644

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/init.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#define _GNU_SOURCE
2+
#include <stdbool.h>
23
#include <stdio.h>
34
#include <stdlib.h>
45
#include <string.h>
@@ -1393,9 +1394,13 @@ static int hyper_setup_init_process(void)
13931394

13941395
int main(int argc, char *argv[])
13951396
{
1396-
char *cmdline, *ctl_serial, *tty_serial;
1397+
char *binary_name, *cmdline, *ctl_serial, *tty_serial;
1398+
bool is_init;
13971399

1398-
if (hyper_setup_init_process() < 0) {
1400+
binary_name = basename(argv[0]);
1401+
is_init = strncmp(binary_name, "init", 5) == 0;
1402+
1403+
if (is_init && hyper_setup_init_process() < 0) {
13991404
return -1;
14001405
}
14011406

0 commit comments

Comments
 (0)