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:
Joachim Wiberg committed 2025-12-31 23:34:04 +01:00
1 parent d0176612c9
commit ce40e2b9d2
4 files changed
+33 -2

No files matched your search

+24
View File
@@ -32,6 +32,7 @@
#include <stdarg.h>
#include <sysexits.h>
#include <sys/ioctl.h>
#include <sys/prctl.h>
#ifdef _LIBITE_LITE
# include <libite/lite.h>
#else
@@ -527,6 +528,29 @@ int in_container(void)
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:
* indent-tabs-mode: t