UTMP: Add support for INIT_PROCESS & DEAD_PROCESS

Services started by Finit are now properly accounted for in UTMP.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2016-08-09 00:58:00 +02:00
1 parent 8c54fde36c
commit 2718c709aa
4 files changed
+67 -20

No files matched your search

+10 -2
View File
@@ -32,8 +32,9 @@
#include <lite/lite.h>
#include "finit.h"
#include "sig.h"
#include "helpers.h"
#include "sig.h"
#include "utmp-api.h"
#define NUM_ARGS 16
@@ -105,6 +106,9 @@ int run(char *cmd)
for (i = 1; i < NSIG; i++)
DFLSIG(sa, i, 0);
/* Set INIT_PROCESS UTMP entry */
utmp_set_init(ttyname(0), 0);
/* Always redirect stdio for run() */
fp = fopen("/dev/null", "w");
if (fp) {
@@ -216,13 +220,17 @@ int getty(char *tty, char *baud, char *term);
pid_t run_getty(char *tty, char *speed, char *term, int console)
{
pid_t pid = fork();
pid_t pid;
pid = fork();
if (!pid) {
/* Reset signal handlers that were set by the parent process */
sig_unblock();
setsid();
/* Set INIT_PROCESS UTMP entry */
utmp_set_init(tty, 0);
if (console)
prctl(PR_SET_NAME, "console", 0, 0, 0);
else