[lxc-devel] [PATCH] Allow unsetting daemonize and close_fds
Stéphane Graber
stgraber at ubuntu.com
Fri Nov 29 22:18:43 UTC 2013
On Fri, Nov 29, 2013 at 04:16:46PM -0600, Serge Hallyn wrote:
> Quoting Stéphane Graber (stgraber at ubuntu.com):
> > On Fri, Nov 29, 2013 at 02:40:35PM -0500, S.Çağlar Onur wrote:
> > > On Fri, Nov 29, 2013 at 2:34 PM, Serge Hallyn <serge.hallyn at ubuntu.com> wrote:
> > > > Quoting Stéphane Graber (stgraber at ubuntu.com):
> > > >> As mentioned in a previous commit, this does two changes:
> > > >> - Make want_daemonize return a bool (false on failure, true on success)
> > > >> - Make both want_daemonize and want_close_all_fds take a "state"
> > > >> argument so the user can choose to unset those flags.
> > > >>
> > > >> This commit also updates all occurences of those two functions.
> > > >>
> > > >> Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
> > > >
> > > > Two comments below. With that and James' comments addressed,
> > > >
> > > > Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>
> > > >
> > > >> ---
> > > >> src/lua-lxc/core.c | 2 +-
> > > >> src/lxc/lxc_start.c | 4 ++--
> > > >> src/lxc/lxccontainer.c | 20 +++++++++++++-------
> > > >> src/lxc/lxccontainer.h | 4 ++--
> > > >> src/python-lxc/lxc.c | 10 ++++++++--
> > > >> src/tests/attach.c | 2 +-
> > > >> src/tests/cgpath.c | 2 +-
> > > >> src/tests/concurrent.c | 2 +-
> > > >> src/tests/console.c | 2 +-
> > > >> src/tests/containertests.c | 2 +-
> > > >> src/tests/createtest.c | 2 +-
> > > >> src/tests/shutdowntest.c | 2 +-
> > > >> 12 files changed, 33 insertions(+), 21 deletions(-)
> > > >>
> > > >> diff --git a/src/lua-lxc/core.c b/src/lua-lxc/core.c
> > > >> index 9492c07..04f2f1d 100644
> > > >> --- a/src/lua-lxc/core.c
> > > >> +++ b/src/lua-lxc/core.c
> > > >> @@ -156,7 +156,7 @@ static int container_start(lua_State *L)
> > > >> argv[j] = NULL;
> > > >> }
> > > >>
> > > >> - c->want_daemonize(c);
> > > >> + c->want_daemonize(c, 1);
> > > >> lua_pushboolean(L, !!c->start(c, useinit, argv));
> > > >> return 1;
> > > >> }
> > > >> diff --git a/src/lxc/lxc_start.c b/src/lxc/lxc_start.c
> > > >> index e537846..2a833a6 100644
> > > >> --- a/src/lxc/lxc_start.c
> > > >> +++ b/src/lxc/lxc_start.c
> > > >> @@ -325,7 +325,7 @@ int main(int argc, char *argv[])
> > > >> }
> > > >>
> > > >> if (my_args.daemonize) {
> > > >> - c->want_daemonize(c);
> > > >> + c->want_daemonize(c, 1);
> > > >> }
> > > >>
> > > >> if (pid_fp != NULL) {
> > > >> @@ -337,7 +337,7 @@ int main(int argc, char *argv[])
> > > >> }
> > > >>
> > > >> if (my_args.close_all_fds)
> > > >> - c->want_close_all_fds(c);
> > > >> + c->want_close_all_fds(c, 1);
> > > >>
> > > >> err = c->start(c, 0, args) ? 0 : -1;
> > > >>
> > > >> diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
> > > >> index 283fbb5..4234760 100644
> > > >> --- a/src/lxc/lxccontainer.c
> > > >> +++ b/src/lxc/lxccontainer.c
> > > >> @@ -455,29 +455,35 @@ static bool lxcapi_load_config(struct lxc_container *c, const char *alt_file)
> > > >> return ret;
> > > >> }
> > > >>
> > > >> -static void lxcapi_want_daemonize(struct lxc_container *c)
> > > >> +static bool lxcapi_want_daemonize(struct lxc_container *c, int state)
> > > >> {
> > > >> + if (state > 1)
> > > >
> > > > What about < 0?
> > >
> > > Why we are not passing a bool instead of int?
> >
> > I based this on similar parameters of other API functions (useinit being
> > one). Though looking back now it seems we have a couple of cases where
> > we're also passing bool in such case...
> >
> > I guess another reason would be if we ever wanted to add finer grained
> > options for those two commands as unlikely as it may be :)
> >
> > Serge: Any preference?
>
> (I assume this question is now obsolete)
>
> -serge
It's indeed, for anyone else following, I ended up converting those to
bool and changing the type of daemonize to match.
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20131129/e28fced5/attachment.pgp>
More information about the lxc-devel
mailing list