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
e81fb060
Commit
e81fb060
authored
Mar 19, 2012
by
Petr Baudis
Browse files
Options
Downloads
Patches
Plain Diff
compctl: Fail more gracefully if ran on a non-compctld enabled machine
parent
10ee133c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
cgroup.c
+8
-0
8 additions, 0 deletions
cgroup.c
cgroup.h
+2
-0
2 additions, 0 deletions
cgroup.h
compctl.c
+9
-0
9 additions, 0 deletions
compctl.c
with
19 additions
and
0 deletions
cgroup.c
+
8
−
0
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
)
...
...
...
...
This diff is collapsed.
Click to expand it.
cgroup.h
+
2
−
0
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
);
...
...
...
...
This diff is collapsed.
Click to expand it.
compctl.c
+
9
−
0
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"
))
{
...
...
...
...
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
sign in
to comment