From 02eccce9355be27b414c7fa4e2f4f13dabdbdb3b Mon Sep 17 00:00:00 2001 From: phk Date: Tue, 11 Jul 2006 18:16:13 +0000 Subject: [PATCH] Give 'exit' CLI command some bite. we may want to be more careful later on. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@437 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/mgt.h | 1 + varnish-cache/bin/varnishd/mgt_child.c | 10 ++++++++++ varnish-cache/bin/varnishd/varnishd.c | 12 +++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/varnish-cache/bin/varnishd/mgt.h b/varnish-cache/bin/varnishd/mgt.h index 263c5581..b3488049 100644 --- a/varnish-cache/bin/varnishd/mgt.h +++ b/varnish-cache/bin/varnishd/mgt.h @@ -8,6 +8,7 @@ extern struct event_base *mgt_eb; void mgt_child_start(void); void mgt_child_stop(void); +void mgt_child_kill(void); void mgt_sigchld(int, short, void *); typedef void mgt_ccb_f(unsigned, const char *, void *); diff --git a/varnish-cache/bin/varnishd/mgt_child.c b/varnish-cache/bin/varnishd/mgt_child.c index aa84bb2a..410c4527 100644 --- a/varnish-cache/bin/varnishd/mgt_child.c +++ b/varnish-cache/bin/varnishd/mgt_child.c @@ -282,6 +282,16 @@ mgt_child_stop(void) /*--------------------------------------------------------------------*/ +void +mgt_child_kill(void) +{ + + desired = H_STOP; + kill(child_pid, 9); +} + +/*--------------------------------------------------------------------*/ + void mgt_sigchld(int a, short b, void *c) { diff --git a/varnish-cache/bin/varnishd/varnishd.c b/varnish-cache/bin/varnishd/varnishd.c index 4d15519a..d7321267 100644 --- a/varnish-cache/bin/varnishd/varnishd.c +++ b/varnish-cache/bin/varnishd/varnishd.c @@ -239,6 +239,16 @@ m_cli_func_server_stop(struct cli *cli, char **av, void *priv) /*--------------------------------------------------------------------*/ +static void +m_cli_func_exit(struct cli *cli, char **av, void *priv) +{ + + mgt_child_kill(); + exit (0); +} + +/*--------------------------------------------------------------------*/ + static void m_cli_func_verbose(struct cli *cli, char **av, void *priv) { @@ -304,7 +314,7 @@ static struct cli_proto cli_proto[] = { { CLI_ZERO }, { CLI_HELP, cli_func_help, cli_proto }, { CLI_VERBOSE, m_cli_func_verbose, NULL }, - { CLI_EXIT }, + { CLI_EXIT, m_cli_func_exit, NULL}, { CLI_QUIT }, { CLI_BYE }, { NULL } -- 2.39.5