Commit a7ccae79 authored by Petr Baudis's avatar Petr Baudis
Browse files

stop -> kill, pointed out by mj to be less confusing

parent 0d76062b
......@@ -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
......@@ -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>.
......@@ -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) {
......
......@@ -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)) {
......
Supports Markdown
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