chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
util: modernize readlink_malloc() a bit
[elogind.git]
/
src
/
shared
/
cgroup-util.c
diff --git
a/src/shared/cgroup-util.c
b/src/shared/cgroup-util.c
index 855c9cd160c19c2794822d41363c1c357d572986..e6ceb99454b8460408c64f9797b0ed884e04624c 100644
(file)
--- a/
src/shared/cgroup-util.c
+++ b/
src/shared/cgroup-util.c
@@
-194,12
+194,12
@@
int cg_kill(const char *controller, const char *path, int sig, bool sigcont, boo
if (kill(pid, sig) < 0) {
if (ret >= 0 && errno != ESRCH)
ret = -errno;
if (kill(pid, sig) < 0) {
if (ret >= 0 && errno != ESRCH)
ret = -errno;
- } else if (ret == 0) {
-
+ } else {
if (sigcont)
kill(pid, SIGCONT);
if (sigcont)
kill(pid, SIGCONT);
- ret = 1;
+ if (ret == 0)
+ ret = 1;
}
done = false;
}
done = false;
@@
-1332,11
+1332,10
@@
int cg_pid_get_machine_name(pid_t pid, char **machine) {
int cg_path_get_session(const char *path, char **session) {
const char *e, *n, *x;
int cg_path_get_session(const char *path, char **session) {
const char *e, *n, *x;
- char *s
, *r
;
+ char *s;
size_t l;
assert(path);
size_t l;
assert(path);
- assert(session);
/* Skip slices, if there are any */
e = skip_slices(path);
/* Skip slices, if there are any */
e = skip_slices(path);
@@
-1358,11
+1357,16
@@
int cg_path_get_session(const char *path, char **session) {
if (l <= 6)
return -ENOENT;
if (l <= 6)
return -ENOENT;
- r = strndup(x, l - 6);
- if (!r)
- return -ENOMEM;
+ if (session) {
+ char *r;
+
+ r = strndup(x, l - 6);
+ if (!r)
+ return -ENOMEM;
+
+ *session = r;
+ }
- *session = r;
return 0;
}
return 0;
}
@@
-1370,8
+1374,6
@@
int cg_pid_get_session(pid_t pid, char **session) {
_cleanup_free_ char *cgroup = NULL;
int r;
_cleanup_free_ char *cgroup = NULL;
int r;
- assert(session);
-
r = cg_pid_get_path_shifted(pid, NULL, &cgroup);
if (r < 0)
return r;
r = cg_pid_get_path_shifted(pid, NULL, &cgroup);
if (r < 0)
return r;