Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
compctl-kam
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Mareš
compctl-kam
Commits
a7ccae79
Commit
a7ccae79
authored
13 years ago
by
Petr Baudis
Browse files
Options
Downloads
Patches
Plain Diff
stop -> kill, pointed out by mj to be less confusing
parent
0d76062b
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.client
+5
-5
5 additions, 5 deletions
README.client
compctl.1
+3
-3
3 additions, 3 deletions
compctl.1
compctl.c
+10
-10
10 additions, 10 deletions
compctl.c
compctld.c
+8
-8
8 additions, 8 deletions
compctld.c
with
26 additions
and
26 deletions
README.client
+
5
−
5
View file @
a7ccae79
...
@@ -10,8 +10,8 @@ Usage
...
@@ -10,8 +10,8 @@ Usage
compctl --usage
compctl --usage
compctl --limitmem MAXMEM
compctl --limitmem MAXMEM
compctl --list
compctl --list
compctl --
stop
PGRP
compctl --
kill
PGRP
compctl --
stop
all
compctl --
kill
all
Arguments for running computations:
Arguments for running computations:
--run COMMAND run a new computation on foreground
--run COMMAND run a new computation on foreground
...
@@ -22,8 +22,8 @@ Arguments for controlling computations:
...
@@ -22,8 +22,8 @@ Arguments for controlling computations:
--usage show resource usage of all running computations
--usage show resource usage of all running computations
--limitmem MAXMEM set the maximum memory consumed by all computations [MiB]
--limitmem MAXMEM set the maximum memory consumed by all computations [MiB]
--list list all running computations
--list list all running computations
--
stop
PGRP
stop
a given computation (number as listed in --list)
--
kill
PGRP
kill
a given computation (number as listed in --list)
--
stop
all
stop
all running computations
--
kill
all
kill
all running computations
Other options:
Other options:
--help help message
--help help message
...
@@ -44,4 +44,4 @@ Examples
...
@@ -44,4 +44,4 @@ Examples
compctl --screen autotest-screen 5
compctl --screen autotest-screen 5
compctl --limitmem 4096
compctl --limitmem 4096
compctl --
stop
27134
compctl --
kill
27134
This diff is collapsed.
Click to expand it.
compctl.1
+
3
−
3
View file @
a7ccae79
...
@@ -34,10 +34,10 @@ compctl \- Computations under control
...
@@ -34,10 +34,10 @@ compctl \- Computations under control
.RI --list
.RI --list
.br
.br
.B compctl
.B compctl
.RI --
stop
" PGRP "
.RI --
kill
" PGRP "
.br
.br
.B compctl
.B compctl
.RI --
stop
all
.RI --
kill
all
.br
.br
.SH DESCRIPTION
.SH DESCRIPTION
\fBComputations under control\fP will run a specificed program as
\fBComputations under control\fP will run a specificed program as
...
@@ -56,7 +56,7 @@ compctl --screen autotest-screen 5
...
@@ -56,7 +56,7 @@ compctl --screen autotest-screen 5
.br
.br
compctl --limitmem 4096
compctl --limitmem 4096
.br
.br
compctl --
stop
27134
compctl --
kill
27134
.br
.br
.SH AUTHOR
.SH AUTHOR
\fBcompctl\fP was written by Petr Baudis <pasky@ucw.cz>.
\fBcompctl\fP was written by Petr Baudis <pasky@ucw.cz>.
This diff is collapsed.
Click to expand it.
compctl.c
+
10
−
10
View file @
a7ccae79
...
@@ -130,9 +130,9 @@ screen(int argc, char *argv[])
...
@@ -130,9 +130,9 @@ screen(int argc, char *argv[])
}
}
void
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
);
char
*
line
=
daemon_chat
(
cmd
);
if
(
line
[
0
]
!=
'1'
)
{
if
(
line
[
0
]
!=
'1'
)
{
fprintf
(
stderr
,
"%s
\n
"
,
*
line
?
line
:
"unexpected hangup"
);
fprintf
(
stderr
,
"%s
\n
"
,
*
line
?
line
:
"unexpected hangup"
);
...
@@ -142,9 +142,9 @@ stop(pid_t pid)
...
@@ -142,9 +142,9 @@ stop(pid_t pid)
}
}
void
void
stop
_all
(
void
)
kill
_all
(
void
)
{
{
char
*
line
=
daemon_chat
(
"
stop
all"
);
char
*
line
=
daemon_chat
(
"
kill
all"
);
if
(
line
[
0
]
!=
'1'
)
{
if
(
line
[
0
]
!=
'1'
)
{
fprintf
(
stderr
,
"%s
\n
"
,
*
line
?
line
:
"unexpected hangup"
);
fprintf
(
stderr
,
"%s
\n
"
,
*
line
?
line
:
"unexpected hangup"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
...
@@ -164,7 +164,7 @@ limit_mem(size_t limit)
...
@@ -164,7 +164,7 @@ limit_mem(size_t limit)
fprintf
(
stderr
,
"%s
\n
"
,
*
line
?
line
:
"unexpected hangup"
);
fprintf
(
stderr
,
"%s
\n
"
,
*
line
?
line
:
"unexpected hangup"
);
if
(
line
[
0
]
==
'0'
)
{
if
(
line
[
0
]
==
'0'
)
{
fprintf
(
stderr
,
"Most likely, the computations are already using too much memory.
\n
"
fprintf
(
stderr
,
"Most likely, the computations are already using too much memory.
\n
"
"Consider
stopp
ing some of them first.
\n
"
);
"Consider
kill
ing some of them first.
\n
"
);
}
}
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
...
@@ -224,15 +224,15 @@ main(int argc, char *argv[])
...
@@ -224,15 +224,15 @@ main(int argc, char *argv[])
}
else
if
(
!
strcmp
(
cmd
,
"--list"
))
{
}
else
if
(
!
strcmp
(
cmd
,
"--list"
))
{
list
();
list
();
}
else
if
(
!
strcmp
(
cmd
,
"--
stop
"
))
{
}
else
if
(
!
strcmp
(
cmd
,
"--
kill
"
))
{
if
(
argc
<=
optind
)
{
if
(
argc
<=
optind
)
{
fputs
(
"missing argument for --
stop
\n
"
,
stderr
);
fputs
(
"missing argument for --
kill
\n
"
,
stderr
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
stop
(
atoi
(
argv
[
optind
++
]));
kill_task
(
atoi
(
argv
[
optind
++
]));
}
else
if
(
!
strcmp
(
cmd
,
"--
stop
all"
))
{
}
else
if
(
!
strcmp
(
cmd
,
"--
kill
all"
))
{
stop
_all
();
kill
_all
();
}
else
if
(
!
strcmp
(
cmd
,
"--limitmem"
))
{
}
else
if
(
!
strcmp
(
cmd
,
"--limitmem"
))
{
if
(
argc
<=
optind
)
{
if
(
argc
<=
optind
)
{
...
...
This diff is collapsed.
Click to expand it.
compctld.c
+
8
−
8
View file @
a7ccae79
...
@@ -205,12 +205,12 @@ sockerror:
...
@@ -205,12 +205,12 @@ sockerror:
else
else
mprintf
(
fd
,
"1 blessed"
);
mprintf
(
fd
,
"1 blessed"
);
}
else
if
(
begins_with
(
"
stop
"
,
line
))
{
}
else
if
(
begins_with
(
"
kill
"
,
line
))
{
pid_t
pid
=
atoi
(
line
+
strlen
(
"
stop
"
));
pid_t
pid
=
atoi
(
line
+
strlen
(
"
kill
"
));
/* Sanity check. */
/* Sanity check. */
if
(
pid
<
10
)
{
if
(
pid
<
10
)
{
syslog
(
LOG_WARNING
,
"
stop
: invalid pid (%d)"
,
pid
);
syslog
(
LOG_WARNING
,
"
kill
: invalid pid (%d)"
,
pid
);
mprintf
(
fd
,
"0 invalid pid"
);
mprintf
(
fd
,
"0 invalid pid"
);
close
(
fd
);
close
(
fd
);
continue
;
continue
;
...
@@ -221,12 +221,12 @@ sockerror:
...
@@ -221,12 +221,12 @@ sockerror:
continue
;
continue
;
}
}
syslog
(
LOG_INFO
,
"
stopp
ing process %d (request by pid %d uid %d)"
,
pid
,
cred
->
pid
,
cred
->
uid
);
syslog
(
LOG_INFO
,
"
kill
ing process %d (request by pid %d uid %d)"
,
pid
,
cred
->
pid
,
cred
->
uid
);
kill
(
pid
,
SIGTERM
);
kill
(
pid
,
SIGTERM
);
/* TODO: Grace period and then kill with SIGKILL. */
/* TODO: Grace period and then kill with SIGKILL. */
mprintf
(
fd
,
"1 task
stopp
ed"
);
mprintf
(
fd
,
"1 task
kill
ed"
);
}
else
if
(
!
strcmp
(
"
stop
all"
,
line
))
{
}
else
if
(
!
strcmp
(
"
kill
all"
,
line
))
{
pid_t
*
tasks
;
pid_t
*
tasks
;
int
tasks_n
=
cgroup_task_list
(
chier
,
cgroup
,
&
tasks
);
int
tasks_n
=
cgroup_task_list
(
chier
,
cgroup
,
&
tasks
);
if
(
tasks_n
<
0
)
{
if
(
tasks_n
<
0
)
{
...
@@ -235,11 +235,11 @@ sockerror:
...
@@ -235,11 +235,11 @@ sockerror:
continue
;
continue
;
}
}
for
(
int
i
=
0
;
i
<
tasks_n
;
i
++
)
{
for
(
int
i
=
0
;
i
<
tasks_n
;
i
++
)
{
syslog
(
LOG_INFO
,
"
stopp
ing process %d (mass request by pid %d uid %d)"
,
tasks
[
i
],
cred
->
pid
,
cred
->
uid
);
syslog
(
LOG_INFO
,
"
kill
ing process %d (mass request by pid %d uid %d)"
,
tasks
[
i
],
cred
->
pid
,
cred
->
uid
);
kill
(
tasks
[
i
],
SIGTERM
);
kill
(
tasks
[
i
],
SIGTERM
);
}
}
/* TODO: Grace period and then kill with SIGKILL. */
/* TODO: Grace period and then kill with SIGKILL. */
mprintf
(
fd
,
"1 %d tasks
stopp
ed"
,
tasks_n
);
mprintf
(
fd
,
"1 %d tasks
kill
ed"
,
tasks_n
);
free
(
tasks
);
free
(
tasks
);
}
else
if
(
begins_with
(
"limitmem "
,
line
))
{
}
else
if
(
begins_with
(
"limitmem "
,
line
))
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment