summaryrefslogtreecommitdiff
path: root/src/shared/cgroup-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-01-27 21:34:54 +0100
committerLennart Poettering <lennart@poettering.net>2014-01-27 21:34:54 +0100
commitaf08d2f9cde8f46d9d3e731dbd1f06ffb3b08942 (patch)
tree0906d724d8d6f2ed59ed8c4fef021f267810b696 /src/shared/cgroup-util.c
parent968d3d242cc9256eaca9a18155a744b575159cbd (diff)
bus: add API calls for connecting to starter bus
Add new calls sd_bus_open() and sd_bus_default() for connecting to the starter bus a service was invoked for, or -- if the process is not a bus-activated service -- the appropriate bus for the scope the process has been started in.
Diffstat (limited to 'src/shared/cgroup-util.c')
-rw-r--r--src/shared/cgroup-util.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/shared/cgroup-util.c b/src/shared/cgroup-util.c
index 855c9cd160..4ce885601f 100644
--- a/src/shared/cgroup-util.c
+++ b/src/shared/cgroup-util.c
@@ -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;
- char *s, *r;
+ char *s;
size_t l;
assert(path);
- assert(session);
/* 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;
- 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;
}
@@ -1370,8 +1374,6 @@ int cg_pid_get_session(pid_t pid, char **session) {
_cleanup_free_ char *cgroup = NULL;
int r;
- assert(session);
-
r = cg_pid_get_path_shifted(pid, NULL, &cgroup);
if (r < 0)
return r;