2
* lxc: linux Container library
4
* (C) Copyright IBM Corp. 2007, 2008
7
* Daniel Lezcano <dlezcano at fr.ibm.com>
9
* This library is free software; you can redistribute it and/or
10
* modify it under the terms of the GNU Lesser General Public
11
* License as published by the Free Software Foundation; either
12
* version 2.1 of the License, or (at your option) any later version.
14
* This library is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
* Lesser General Public License for more details.
19
* You should have received a copy of the GNU Lesser General Public
20
* License along with this library; if not, write to the Free Software
21
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31
lxc_log_define(lxc_execute, lxc_start);
38
static int execute_start(struct lxc_handler *handler, void* data)
41
struct execute_args *my_args = data;
45
while (my_args->argv[argc++]);
47
argv = malloc((argc + my_args->quiet ? 5 : 4) * sizeof(*argv));
51
argv[i++] = LXCINITDIR "/lxc-init";
53
argv[i++] = "--quiet";
55
for (j = 0; j < argc; j++)
56
argv[i++] = my_args->argv[j];
59
NOTICE("exec'ing '%s'", my_args->argv[0]);
61
execvp(argv[0], argv);
62
SYSERROR("failed to exec %s", argv[0]);
66
static int execute_post_start(struct lxc_handler *handler, void* data)
68
struct execute_args *my_args = data;
69
NOTICE("'%s' started with pid '%d'", my_args->argv[0], handler->pid);
73
static struct lxc_operations execute_start_ops = {
74
.start = execute_start,
75
.post_start = execute_post_start
78
int lxc_execute(const char *name, char *const argv[], int quiet,
79
struct lxc_conf *conf)
81
struct execute_args args = {
86
if (lxc_check_inherited(conf, -1))
89
return __lxc_start(name, conf, &execute_start_ops, &args);