Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Martin Mareš
compctl-kam
Commits
e81fb060
Commit
e81fb060
authored
Mar 19, 2012
by
Petr Baudis
Browse files
compctl: Fail more gracefully if ran on a non-compctld enabled machine
parent
10ee133c
Changes
3
Hide whitespace changes
Inline
Side-by-side
cgroup.c
View file @
e81fb060
...
...
@@ -55,6 +55,14 @@ cgroup_create(const char *chier, const char *cgroup)
return
1
;
}
bool
cgroup_available
(
const
char
*
chier
,
const
char
*
cgroup
)
{
char
cgroupdir
[
PATH_MAX
];
snprintf
(
cgroupdir
,
sizeof
(
cgroupdir
),
"%s%s/%s"
,
cgroupfs
,
chier
,
cgroup
);
return
(
access
(
cgroupdir
,
F_OK
)
>=
0
);
}
int
cgroup_add_task
(
const
char
*
chier
,
const
char
*
cgroup
,
pid_t
pid
)
...
...
cgroup.h
View file @
e81fb060
...
...
@@ -18,6 +18,8 @@ int cgroup_setup(const char *chier, const char *controllers);
/* Setup a given control group. Return 0 if cgroups already set up,
* 1 on success, -1 on failure. */
int
cgroup_create
(
const
char
*
chier
,
const
char
*
cgroup
);
/* Return true if cgroup control is set up, false otherwise. */
bool
cgroup_available
(
const
char
*
chier
,
const
char
*
cgroup
);
/* Add a task to a given cgroup. Return 1 on success, -1 on failure. */
int
cgroup_add_task
(
const
char
*
chier
,
const
char
*
cgroup
,
pid_t
pid
);
...
...
compctl.c
View file @
e81fb060
...
...
@@ -20,6 +20,7 @@ daemon_chat(char *cmd)
struct
sockaddr_un
sun
=
{
.
sun_family
=
AF_UNIX
,
.
sun_path
=
SOCKFILE
};
if
(
connect
(
s
,
(
struct
sockaddr
*
)
&
sun
,
sizeof
(
sun
.
sun_family
)
+
strlen
(
sun
.
sun_path
)
+
1
)
<
0
)
{
perror
(
SOCKFILE
);
fputs
(
"Plese contact "
ADMINCONTACT
" about this error.
\n
"
,
stderr
);
exit
(
EXIT_FAILURE
);
}
...
...
@@ -202,6 +203,14 @@ main(int argc, char *argv[])
return
EXIT_FAILURE
;
}
if
(
!
cgroup_available
(
chier
,
cgroup
))
{
fputs
(
"CGroup-based computation control is not available on this host.
\n
"
,
stderr
);
fputs
(
"Most likely, this computer is not meant for computations,
\n
"
,
stderr
);
fputs
(
"please consider switching to a different host.
\n
"
,
stderr
);
fputs
(
"Plese contact "
ADMINCONTACT
" if you believe this is an error.
\n
"
,
stderr
);
return
EXIT_FAILURE
;
}
while
(
argc
>
optind
)
{
char
*
cmd
=
argv
[
optind
++
];
if
(
!
strcmp
(
cmd
,
"--run"
))
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment