diff --git a/README.client b/README.client index 14af8396d8e8024991f8736eadf83c0b6e48d54e..d60a4cb9065fb592a14ea04bd13293406fd671aa 100644 --- a/README.client +++ b/README.client @@ -10,8 +10,8 @@ Usage compctl --usage compctl --limitmem MAXMEM compctl --list - compctl --stop PGRP - compctl --stopall + compctl --kill PGRP + compctl --killall Arguments for running computations: --run COMMAND run a new computation on foreground @@ -22,8 +22,8 @@ Arguments for controlling computations: --usage show resource usage of all running computations --limitmem MAXMEM set the maximum memory consumed by all computations [MiB] --list list all running computations - --stop PGRP stop a given computation (number as listed in --list) - --stopall stop all running computations + --kill PGRP kill a given computation (number as listed in --list) + --killall kill all running computations Other options: --help help message @@ -44,4 +44,4 @@ Examples compctl --screen autotest-screen 5 compctl --limitmem 4096 - compctl --stop 27134 + compctl --kill 27134 diff --git a/compctl.1 b/compctl.1 index 37ad3e8743b48745b97e780e9d2ed4e5064dd1a1..53b9bcaf0bf0b11e637b6495cfeb8a640dc91285 100644 --- a/compctl.1 +++ b/compctl.1 @@ -34,10 +34,10 @@ compctl \- Computations under control .RI --list .br .B compctl -.RI --stop " PGRP " +.RI --kill " PGRP " .br .B compctl -.RI --stopall +.RI --killall .br .SH DESCRIPTION \fBComputations under control\fP will run a specificed program as @@ -56,7 +56,7 @@ compctl --screen autotest-screen 5 .br compctl --limitmem 4096 .br -compctl --stop 27134 +compctl --kill 27134 .br .SH AUTHOR \fBcompctl\fP was written by Petr Baudis <pasky@ucw.cz>. diff --git a/compctl.c b/compctl.c index f1bba58c5eb2977c43788e96cbde968dbfe943b6..80b150babe93610826772f03f63e81daa8d4018a 100644 --- a/compctl.c +++ b/compctl.c @@ -130,9 +130,9 @@ screen(int argc, char *argv[]) } void -stop(pid_t pid) +kill_task(pid_t pid) { - char cmd[256]; snprintf(cmd, sizeof(cmd), "stop %d", pid); + char cmd[256]; snprintf(cmd, sizeof(cmd), "kill %d", pid); char *line = daemon_chat(cmd); if (line[0] != '1') { fprintf(stderr, "%s\n", *line ? line : "unexpected hangup"); @@ -142,9 +142,9 @@ stop(pid_t pid) } void -stop_all(void) +kill_all(void) { - char *line = daemon_chat("stopall"); + char *line = daemon_chat("killall"); if (line[0] != '1') { fprintf(stderr, "%s\n", *line ? line : "unexpected hangup"); exit(EXIT_FAILURE); @@ -164,7 +164,7 @@ limit_mem(size_t limit) fprintf(stderr, "%s\n", *line ? line : "unexpected hangup"); if (line[0] == '0') { fprintf(stderr, "Most likely, the computations are already using too much memory.\n" - "Consider stopping some of them first.\n"); + "Consider killing some of them first.\n"); } exit(EXIT_FAILURE); } @@ -224,15 +224,15 @@ main(int argc, char *argv[]) } else if (!strcmp(cmd, "--list")) { list(); - } else if (!strcmp(cmd, "--stop")) { + } else if (!strcmp(cmd, "--kill")) { if (argc <= optind) { - fputs("missing argument for --stop\n", stderr); + fputs("missing argument for --kill\n", stderr); exit(EXIT_FAILURE); } - stop(atoi(argv[optind++])); + kill_task(atoi(argv[optind++])); - } else if (!strcmp(cmd, "--stopall")) { - stop_all(); + } else if (!strcmp(cmd, "--killall")) { + kill_all(); } else if (!strcmp(cmd, "--limitmem")) { if (argc <= optind) { diff --git a/compctld.c b/compctld.c index 27c551191ef949b984499795fb95a8e0507fcca8..5e41ff47ba8e67635c3e22fecc143404cdfca5b8 100644 --- a/compctld.c +++ b/compctld.c @@ -205,12 +205,12 @@ sockerror: else mprintf(fd, "1 blessed"); - } else if (begins_with("stop ", line)) { - pid_t pid = atoi(line + strlen("stop ")); + } else if (begins_with("kill ", line)) { + pid_t pid = atoi(line + strlen("kill ")); /* Sanity check. */ if (pid < 10) { - syslog(LOG_WARNING, "stop: invalid pid (%d)", pid); + syslog(LOG_WARNING, "kill: invalid pid (%d)", pid); mprintf(fd, "0 invalid pid"); close(fd); continue; @@ -221,12 +221,12 @@ sockerror: continue; } - syslog(LOG_INFO, "stopping process %d (request by pid %d uid %d)", pid, cred->pid, cred->uid); + syslog(LOG_INFO, "killing process %d (request by pid %d uid %d)", pid, cred->pid, cred->uid); kill(pid, SIGTERM); /* TODO: Grace period and then kill with SIGKILL. */ - mprintf(fd, "1 task stopped"); + mprintf(fd, "1 task killed"); - } else if (!strcmp("stopall", line)) { + } else if (!strcmp("killall", line)) { pid_t *tasks; int tasks_n = cgroup_task_list(chier, cgroup, &tasks); if (tasks_n < 0) { @@ -235,11 +235,11 @@ sockerror: continue; } for (int i = 0; i < tasks_n; i++) { - syslog(LOG_INFO, "stopping process %d (mass request by pid %d uid %d)", tasks[i], cred->pid, cred->uid); + syslog(LOG_INFO, "killing process %d (mass request by pid %d uid %d)", tasks[i], cred->pid, cred->uid); kill(tasks[i], SIGTERM); } /* TODO: Grace period and then kill with SIGKILL. */ - mprintf(fd, "1 %d tasks stopped", tasks_n); + mprintf(fd, "1 %d tasks killed", tasks_n); free(tasks); } else if (begins_with("limitmem ", line)) {