[lxc-devel] [PATCH] fix wait status in pid reuse case
Serge Hallyn
serge.hallyn at ubuntu.com
Mon Apr 8 17:30:47 UTC 2013
Quoting Dwight Engen (dwight.engen at oracle.com):
> 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: Dwight Engen <dwight.engen at oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>
> ---
> src/lxc/lxc_init.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/src/lxc/lxc_init.c b/src/lxc/lxc_init.c
> index 5693da5..c83c2f1 100644
> --- a/src/lxc/lxc_init.c
> +++ b/src/lxc/lxc_init.c
> @@ -63,7 +63,7 @@ int main(int argc, char *argv[])
> int err = -1;
> char **aargv;
> sigset_t mask, omask;
> - int i, shutdown = 0;
> + int i, have_status = 0, shutdown = 0;
>
> while (1) {
> int ret = getopt_long_only(argc, argv, "", options, NULL);
> @@ -162,7 +162,6 @@ int main(int argc, char *argv[])
> err = 0;
> for (;;) {
> int status;
> - int orphan = 0;
> pid_t waited_pid;
>
> switch (was_interrupted) {
> @@ -209,10 +208,10 @@ int main(int argc, char *argv[])
> * (not wrapped pid) and continue to wait for
> * the end of the orphan group.
> */
> - if ((waited_pid != pid) || (orphan ==1))
> - continue;
> - orphan = 1;
> - err = lxc_error_set_and_log(waited_pid, status);
> + if (waited_pid == pid && !have_status) {
> + err = lxc_error_set_and_log(waited_pid, status);
> + have_status = 1;
> + }
> }
> out:
> return err;
> --
> 1.7.12.3
>
>
> ------------------------------------------------------------------------------
> Minimize network downtime and maximize team effectiveness.
> Reduce network management and security costs.Learn how to hire
> the most talented Cisco Certified professionals. Visit the
> Employer Resources Portal
> http://www.cisco.com/web/learning/employer_resources/index.html
> _______________________________________________
> Lxc-devel mailing list
> Lxc-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-devel
More information about the lxc-devel
mailing list