Commit fe19f236 by Dwight Engen Committed by Serge Hallyn

fix wait status in pid reuse case

Commit 37c3dfc9 sets the wait status on only the child pid. It intended to match the pid only once to protect against pid reuse but it won't because the indicator was reset to 0 every time at the top of the loop. If the child pid is reused, the wait status will be set again. Fix by setting indicator outside the loop. Signed-off-by: 's avatarDwight Engen <dwight.engen@oracle.com> Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com>
parent 1354f952
...@@ -63,7 +63,7 @@ int main(int argc, char *argv[]) ...@@ -63,7 +63,7 @@ int main(int argc, char *argv[])
int err = -1; int err = -1;
char **aargv; char **aargv;
sigset_t mask, omask; sigset_t mask, omask;
int i, shutdown = 0; int i, have_status = 0, shutdown = 0;
while (1) { while (1) {
int ret = getopt_long_only(argc, argv, "", options, NULL); int ret = getopt_long_only(argc, argv, "", options, NULL);
...@@ -162,7 +162,6 @@ int main(int argc, char *argv[]) ...@@ -162,7 +162,6 @@ int main(int argc, char *argv[])
err = 0; err = 0;
for (;;) { for (;;) {
int status; int status;
int orphan = 0;
pid_t waited_pid; pid_t waited_pid;
switch (was_interrupted) { switch (was_interrupted) {
...@@ -209,10 +208,10 @@ int main(int argc, char *argv[]) ...@@ -209,10 +208,10 @@ int main(int argc, char *argv[])
* (not wrapped pid) and continue to wait for * (not wrapped pid) and continue to wait for
* the end of the orphan group. * the end of the orphan group.
*/ */
if ((waited_pid != pid) || (orphan ==1)) if (waited_pid == pid && !have_status) {
continue; err = lxc_error_set_and_log(waited_pid, status);
orphan = 1; have_status = 1;
err = lxc_error_set_and_log(waited_pid, status); }
} }
out: out:
return err; return err;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment