Skip to content

Commit

Permalink
Merge pull request #11073 from giuseppe/fix-zombie-process-first-run
Browse files Browse the repository at this point in the history
rootless: avoid zombie process on first launch
  • Loading branch information
openshift-merge-robot authored Jul 29, 2021
2 parents 2041731 + 724d048 commit 0f42cce
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions pkg/rootless/rootless_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,38 +465,43 @@ reexec_in_user_namespace_wait (int pid, int options)
static int
create_pause_process (const char *pause_pid_file_path, char **argv)
{
int r, p[2];
pid_t pid;
int p[2];

if (pipe (p) < 0)
_exit (EXIT_FAILURE);
return -1;

r = fork ();
if (r < 0)
_exit (EXIT_FAILURE);
pid = fork ();
if (pid < 0)
{
close (p[0]);
close (p[1]);
return -1;
}

if (r)
if (pid)
{
char b;
int r;

close (p[1]);
/* Block until we write the pid file. */
r = TEMP_FAILURE_RETRY (read (p[0], &b, 1));
close (p[0]);

reexec_in_user_namespace_wait (r, 0);
reexec_in_user_namespace_wait (pid, 0);

return r == 1 && b == '0' ? 0 : -1;
}
else
{
int fd;
pid_t pid;
int r, fd;

close (p[0]);

setsid ();
pid = fork ();
if (r < 0)
if (pid < 0)
_exit (EXIT_FAILURE);

if (pid)
Expand Down

0 comments on commit 0f42cce

Please sign in to comment.