Alright, indeed interesting, I've dropped exit_value and used the error_num instead. V3 is much simpler.
Thanks Serge. Signed-off-by: Rodrigo Sampaio Vaz <[email protected]> --- diff --git a/src/lxc/lxc_start.c b/src/lxc/lxc_start.c index 1d8145f..03ce079 100644 --- a/src/lxc/lxc_start.c +++ b/src/lxc/lxc_start.c @@ -336,6 +336,9 @@ int main(int argc, char *argv[]) ERROR("To get more details, run the container in foreground mode."); ERROR("Additional information can be obtained by setting the " "--logfile and --log-priority options."); + err = c->error_num; + lxc_container_put(c); + return err; } out: diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index 62e38d7..e2a7a68 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -669,6 +669,7 @@ static bool lxcapi_start(struct lxc_container *c, int useinit, char * const argv reboot: conf->reboot = 0; ret = lxc_start(c->name, argv, conf, c->config_path); + c->error_num = ret; if (conf->reboot) { INFO("container requested reboot"); --- On Thu, Jul 3, 2014 at 3:21 PM, Serge Hallyn <[email protected]> wrote: > Quoting Rodrigo Vaz ([email protected]): > > Hi Serge, > > > > Thanks for the comment and it makes a lot of sense, here is the V2 patch. > > Thanks, just one more comment, > > > Signed-off-by: Rodrigo Sampaio Vaz <[email protected]> > > --- > > src/lxc/lxc_start.c | 2 ++ > > src/lxc/lxccontainer.c | 1 + > > src/lxc/lxccontainer.h | 3 +++ > > 3 files changed, 6 insertions(+) > > > > diff --git a/src/lxc/lxc_start.c b/src/lxc/lxc_start.c > > index 1d8145f..6212422 100644 > > --- a/src/lxc/lxc_start.c > > +++ b/src/lxc/lxc_start.c > > @@ -336,6 +336,8 @@ int main(int argc, char *argv[]) > > ERROR("To get more details, run the container in foreground mode."); > > ERROR("Additional information can be obtained by setting the " > > "--logfile and --log-priority options."); > > + lxc_container_put(c); > > + return c->exit_value; > > You should grab the error value before doing the lxc_container_put(). > So perhaps > > err = c->exit_value; > lxc_container_put(c); > return err; > > > } > > > > out: > > diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c > > index 62e38d7..cb26fff 100644 > > --- a/src/lxc/lxccontainer.c > > +++ b/src/lxc/lxccontainer.c > > @@ -669,6 +669,7 @@ static bool lxcapi_start(struct lxc_container *c, int > > useinit, char * const argv > > reboot: > > conf->reboot = 0; > > ret = lxc_start(c->name, argv, conf, c->config_path); > > + c->exit_value = ret; > > > > if (conf->reboot) { > > INFO("container requested reboot"); > > diff --git a/src/lxc/lxccontainer.h b/src/lxc/lxccontainer.h > > index 1d0628a..0fb8eb1 100644 > > --- a/src/lxc/lxccontainer.h > > +++ b/src/lxc/lxccontainer.h > > @@ -106,6 +106,9 @@ struct lxc_container { > > /*! Last error number */ > > int error_num; > > (Hm, this is intersting, error_num shows up nowhere else in the source.) > > > > > + /*! Container exit code */ > > + int exit_value; > > + > > /*! Whether container wishes to be daemonized */ > > bool daemonize; > > > > -- > > 2.0.1 > _______________________________________________ > lxc-devel mailing list > [email protected] > http://lists.linuxcontainers.org/listinfo/lxc-devel >
_______________________________________________ lxc-devel mailing list [email protected] http://lists.linuxcontainers.org/listinfo/lxc-devel
