Skip to content

Commit

Permalink
container: Set primary process to 1 via LISTEN_PID by default if prim…
Browse files Browse the repository at this point in the history
…ary configuration is missing

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
  • Loading branch information
flouthoc committed Aug 25, 2021
1 parent 6ecf5a5 commit 02d085d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@ tests/tests_*
tests/*.log
tests/*.trs
test-suite.log
tags
7 changes: 7 additions & 0 deletions src/libcrun/container.c
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,13 @@ container_init_setup (void *args, pid_t own_pid, char *notify_socket, int sync_s
}
}

// set primary process to 1 explicitly if nothing is configured and LISTEN_FD is not set
if (getenv ("LISTEN_PID") == NULL && entrypoint_args->context->preserve_fds == 0)
{
setenv ("LISTEN_PID", "1", 1);
libcrun_warning ("setting LISTEN_PID=1 since no previous configuration was found");
}

if (def->process && def->process->cwd)
if (UNLIKELY (chdir (def->process->cwd) < 0))
return crun_make_error (err, errno, "chdir");
Expand Down

0 comments on commit 02d085d

Please sign in to comment.