Don't allow to delete running containers unless '--force' is
specified. If '--force' is specified, send KILL signal to container
process before deleting it.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
return ret;
}
-static int uxc_delete(char *name)
+static int uxc_delete(char *name, bool force)
{
struct blob_attr *cur, *tb[__CONF_MAX];
int rem, ret = 0;
if (!found)
return ENOENT;
+ if (s && s->running) {
+ if (force) {
+ ret = uxc_kill(name, SIGKILL));
+ if (ret)
+ goto errout;
+
+ } else {
+ ret = EWOULDBLOCK;
+ goto errout;
+ }
+ }
+
if (stat(fname, &sb) == -1) {
ret=ENOENT;
goto errout;
if (optind != argc - 2)
goto usage_out;
- ret = uxc_delete(argv[optind + 1]);
+ ret = uxc_delete(argv[optind + 1], force);
break;
case CMD_CREATE: