diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-10-18 01:18:50 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-10-18 01:18:50 +0200 |
commit | 97ae63e2a9c07ee64ab9f226b9b6121114f1d732 (patch) | |
tree | 75b10ba576630eef8805b28d8616131b99bd7b3d /src/core/service.c | |
parent | c978343015c787713651dff571acb5207367f5f2 (diff) |
service: when invoking service processes in --user mode set MANAGERPID to PID of systemd
Diffstat (limited to 'src/core/service.c')
-rw-r--r-- | src/core/service.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/core/service.c b/src/core/service.c index 7f9a53af46..5742968d91 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -1801,7 +1801,8 @@ static int service_spawn( goto fail; } - if (!(our_env = new0(char*, 4))) { + our_env = new0(char*, 5); + if (!our_env) { r = -ENOMEM; goto fail; } @@ -1824,10 +1825,14 @@ static int service_spawn( goto fail; } - if (!(final_env = strv_env_merge(2, - UNIT(s)->manager->environment, - our_env, - NULL))) { + if (s->meta.manager->running_as != SYSTEMD_SYSTEM) + if (asprintf(our_env + n_env++, "MANAGERPID=%lu", (unsigned long) getpid()) < 0) { + r = -ENOMEM; + goto fail; + } + + final_env = strv_env_merge(2, UNIT(s)->manager->environment, our_env, NULL); + if (!final_env) { r = -ENOMEM; goto fail; } |