summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Golle2020-11-19 17:12:54 +0000
committerDaniel Golle2020-11-21 01:13:13 +0000
commit04a2eddcb1a33fee865b8f09100567bd54d36be7 (patch)
tree34bb9cac1f5f62ddc5005348897a7a1a8b2dbe55
parentc110405181056f14956ccd097b8e4ffe97b2f3ec (diff)
downloadprocd-04a2eddcb1a33fee865b8f09100567bd54d36be7.tar.gz
uxc: make force-delete kill container process
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>
-rw-r--r--uxc.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/uxc.c b/uxc.c
index 3c6942a..9e73b07 100644
--- a/uxc.c
+++ b/uxc.c
@@ -636,7 +636,7 @@ static int uxc_boot(void)
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;
@@ -663,6 +663,18 @@ static int uxc_delete(char *name)
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;
@@ -823,7 +835,7 @@ int main(int argc, char **argv)
if (optind != argc - 2)
goto usage_out;
- ret = uxc_delete(argv[optind + 1]);
+ ret = uxc_delete(argv[optind + 1], force);
break;
case CMD_CREATE: