summaryrefslogtreecommitdiff
path: root/src/execute.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-10-08 16:06:23 +0200
committerLennart Poettering <lennart@poettering.net>2010-10-08 16:07:50 +0200
commit169c1bda807d183a362b47efe0b5b56e9320e430 (patch)
tree9fb56b5009f9842de0364e2fa598598e58e7f0e5 /src/execute.c
parent926e43013353ed8bee614a3dc35dd0da69cdc59f (diff)
service: optionally, create INIT_PROCESS/DEAD_PROCESS entries for a service
This should fix accounting for pam_limits and suchlike. https://bugzilla.redhat.com/show_bug.cgi?id=636036
Diffstat (limited to 'src/execute.c')
-rw-r--r--src/execute.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/execute.c b/src/execute.c
index 6db048c5fc..9c7e0d6b70 100644
--- a/src/execute.c
+++ b/src/execute.c
@@ -54,6 +54,7 @@
#include "tcpwrap.h"
#include "exit-status.h"
#include "missing.h"
+#include "utmp-wtmp.h"
/* This assumes there is a 'tty' group */
#define TTY_MODE 0620
@@ -1129,6 +1130,9 @@ int exec_spawn(ExecCommand *command,
goto fail;
}
+ if (context->utmp_id)
+ utmp_put_init_process(0, context->utmp_id, getpid(), getsid(0), context->tty_path);
+
if (context->user) {
username = context->user;
if (get_user_creds(&username, &uid, &gid, &home) < 0) {
@@ -1604,6 +1608,12 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
"%sKillSignal: SIG%s\n",
prefix, kill_mode_to_string(c->kill_mode),
prefix, signal_to_string(c->kill_signal));
+
+ if (c->utmp_id)
+ fprintf(f,
+ "%sUtmpIdentifier: %s\n",
+ prefix, c->utmp_id);
+
}
void exec_status_start(ExecStatus *s, pid_t pid) {
@@ -1614,7 +1624,7 @@ void exec_status_start(ExecStatus *s, pid_t pid) {
dual_timestamp_get(&s->start_timestamp);
}
-void exec_status_exit(ExecStatus *s, pid_t pid, int code, int status) {
+void exec_status_exit(ExecStatus *s, pid_t pid, int code, int status, const char *utmp_id) {
assert(s);
if ((s->pid && s->pid != pid) ||
@@ -1626,6 +1636,9 @@ void exec_status_exit(ExecStatus *s, pid_t pid, int code, int status) {
s->code = code;
s->status = status;
+
+ if (utmp_id)
+ utmp_put_dead_process(utmp_id, pid, code, status);
}
void exec_status_dump(ExecStatus *s, FILE *f, const char *prefix) {