Commit 122cae21 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov

dump: Add -k (kill dumped) option

Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@gmail.com>
parent d3a30d6b
......@@ -1244,12 +1244,24 @@ int cr_dump_tasks(pid_t pid, struct cr_options *opts)
ret = 0;
err:
if (!opts->final_state != CR_TASK_LEAVE_STOPPED) {
switch (opts->final_state) {
case CR_TASK_LEAVE_RUNNING:
list_for_each_entry(item, &pstree_list, list) {
continue_task(item->pid);
if (opts->leader_only)
break;
}
break;
case CR_TASK_KILL:
list_for_each_entry(item, &pstree_list, list) {
kill_task(item->pid);
if (opts->leader_only)
break;
}
break;
case CR_TASK_LEAVE_STOPPED:
default:
break;
}
free_pstree(&pstree_list);
......
......@@ -227,7 +227,7 @@ int main(int argc, char *argv[])
int opt, idx;
int action = -1;
static const char short_opts[] = "drsp:t:h";
static const char short_opts[] = "drskp:t:h";
static const struct option long_opts[] = {
{ "dump", no_argument, NULL, 'd' },
{ "restore", no_argument, NULL, 'r' },
......@@ -242,6 +242,9 @@ int main(int argc, char *argv[])
memzero_p(&zero_page_entry);
/* Default options */
opts.final_state = CR_TASK_LEAVE_RUNNING;
for (opt = getopt_long(argc, argv, short_opts, long_opts, &idx); opt != -1;
opt = getopt_long(argc, argv, short_opts, long_opts, &idx)) {
switch (opt) {
......@@ -262,6 +265,9 @@ int main(int argc, char *argv[])
case 's':
action = opt;
break;
case 'k':
opts.final_state = CR_TASK_KILL;
break;
case 'h':
default:
goto usage;
......@@ -287,6 +293,6 @@ int main(int argc, char *argv[])
usage:
printk("\nUsage:\n");
printk("\tcrtools ([--dump|-d]|[--show|-s]|[--restore|-r]) (-p|-t) pid\n\n");
printk("\tcrtools ([--dump|-d]|[--show|-s]|[--restore|-r]) [-k] (-p|-t) pid\n\n");
return -1;
}
......@@ -72,6 +72,7 @@ extern void printk(const char *format, ...);
} while (0)
#define stop_task(pid) kill(pid, SIGSTOP)
#define kill_task(pid) kill(pid, SIGKILL)
#define continue_task(pid) kill(pid, SIGCONT)
#define write_ptr(fd, ptr) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment