lxc_start.c revision fae349da89b9ad063f0080970558b7f02ce233c2
/*
* lxc: linux Container library
*
* (C) Copyright IBM Corp. 2007, 2008
*
* Authors:
* Daniel Lezcano <dlezcano at fr.ibm.com>
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <libgen.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <termios.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include "log.h"
#include "lxc.h"
#include "conf.h"
#include "utils.h"
#include "config.h"
#include "confile.h"
#include "arguments.h"
{
switch (c) {
}
return 0;
}
static const struct option my_longopts[] = {
};
static struct lxc_arguments my_args = {
.progname = "lxc-start",
.help = "\
--name=NAME -- COMMAND\n\
\n\
lxc-start start COMMAND in specified container NAME\n\
\n\
Options :\n\
-n, --name=NAME NAME for name of the container\n\
-d, --daemon daemonize the container\n\
-f, --rcfile=FILE Load configuration file FILE\n",
.options = my_longopts,
.daemonize = 0,
};
{
if (!isatty(0))
return 0;
WARN("failed to get current terminal settings : %s",
return 0;
}
{
struct termios current_tios;
void (*oldhandler)(int);
int ret;
if (!isatty(0))
return 0;
if (tcgetattr(0, ¤t_tios)) {
ERROR("failed to get current terminal settings : %s",
return -1;
}
return 0;
if (ret)
ERROR("failed to restore terminal attributes");
return ret;
}
{
char *const *args;
int err = -1;
char *const default_args[] = {
'\0',
};
return err;
args = default_args;
else
return err;
/* rcfile is specified in the cli option */
else {
SYSERROR("failed to allocate memory");
return err;
}
/* container configuration does not exist */
}
}
if (lxc_conf_init(&conf)) {
ERROR("failed to initialze configuration");
return err;
}
ERROR("failed to read configuration file");
return err;
}
/* do not chdir as we want to open the log file,
* change the directory right after.
* do not close 0, 1, 2, we want to do that
* being reopened.
*/
return err;
}
}
}
restore_tty(&tios);
return err;
}