mirror of
https://github.com/troglobit/finit.git
synced 2026-11-02 13:20:32 +00:00
Rename tty services early from "init" -> "getty"
Finit has support for "Please press Enter to activate this console." which means there's no getty yet running. However, when profiling systems with Finit, and embedded systems in general, a common metric is the time from power-on to getty has started. This commit makes sure to rename the process so that BusyBox pidof is capable of detecting that "getty" has started. This is mostly for the bootchart2 project's bootchartd, the native BusyBox bootchartd does not have this issue. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
4 files changed
+33
-2
No files matched your search
+6
-2
@@ -61,8 +61,9 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "utmp-api.h"
|
#include "utmp-api.h"
|
||||||
|
|
||||||
uev_ctx_t *ctx = NULL; /* Main loop context */
|
uev_ctx_t *ctx; /* Main loop context */
|
||||||
svc_t *wdog = NULL; /* No watchdog by default */
|
svc_t *wdog; /* No watchdog by default */
|
||||||
|
char *arg0; /* Saved for setprocnm() */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -609,6 +610,9 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
uev_ctx_t loop;
|
uev_ctx_t loop;
|
||||||
|
|
||||||
|
/* Save argv for setprocnm() in child processes */
|
||||||
|
arg0 = argv[0];
|
||||||
|
|
||||||
/* user calling telinit or init */
|
/* user calling telinit or init */
|
||||||
if (getpid() != 1) {
|
if (getpid() != 1) {
|
||||||
if (geteuid() == 0)
|
if (geteuid() == 0)
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <sysexits.h>
|
#include <sysexits.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/prctl.h>
|
||||||
#ifdef _LIBITE_LITE
|
#ifdef _LIBITE_LITE
|
||||||
# include <libite/lite.h>
|
# include <libite/lite.h>
|
||||||
#else
|
#else
|
||||||
@@ -527,6 +528,29 @@ int in_container(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* setprocnm - Set process name in argv[0] for ps/pidof
|
||||||
|
* @name: New process name to set
|
||||||
|
*
|
||||||
|
* Changes the process name by modifying argv[0]. This is particularly
|
||||||
|
* useful for compatibility with BusyBox's pidof which reads cmdline
|
||||||
|
* from /proc/pid/cmdline rather than /proc/pid/comm.
|
||||||
|
*/
|
||||||
|
void setprocnm(const char *name)
|
||||||
|
{
|
||||||
|
extern char *arg0;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
if (!arg0 || !name)
|
||||||
|
return;
|
||||||
|
|
||||||
|
prctl(PR_SET_NAME, name, 0, 0, 0);
|
||||||
|
|
||||||
|
len = strlen(arg0);
|
||||||
|
memset(arg0, 0, len);
|
||||||
|
strlcpy(arg0, name, len + 1);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Local Variables:
|
* Local Variables:
|
||||||
* indent-tabs-mode: t
|
* indent-tabs-mode: t
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ int print_result (int fail);
|
|||||||
void set_hostname (char **hostname);
|
void set_hostname (char **hostname);
|
||||||
void networking (int updown);
|
void networking (int updown);
|
||||||
int in_container (void);
|
int in_container (void);
|
||||||
|
void setprocnm (const char *name);
|
||||||
|
|
||||||
int complete (char *cmd, int pid);
|
int complete (char *cmd, int pid);
|
||||||
int run (char *cmd, char *log);
|
int run (char *cmd, char *log);
|
||||||
|
|||||||
@@ -569,6 +569,8 @@ static pid_t service_fork(svc_t *svc)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (svc_is_tty(svc))
|
||||||
|
setprocnm("getty");
|
||||||
|
|
||||||
sched_yield();
|
sched_yield();
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user