Skip to content

Commit

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

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
  • Loading branch information
flouthoc committed Aug 25, 2021
1 parent 6ecf5a5 commit fd2c5a6
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 @@ -1187,6 +1187,13 @@ container_init_setup (void *args, pid_t own_pid, char *notify_socket, int sync_s
if (clearenv ())
return crun_make_error (err, errno, "clearenv");

// 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)
{
size_t i;
Expand Down

0 comments on commit fd2c5a6

Please sign in to comment.