TSLOG: Report final execname, not first

In cases such as daemons launched via limits(1), a process may call
exec multiple times; the last name of the last binary executed is
usually (always?) more informative.

Fixes:	46dd801acb23 Add userland boot profiling to TSLOG
Sponsored by:	https://www.patreon.com/cperciva
This commit is contained in:
Colin Percival 2021-10-17 13:36:38 -07:00
parent 0d6516b453
commit 52e125c2bd

View File

@ -169,8 +169,9 @@ tslog_user(pid_t pid, pid_t ppid, const char * execname, const char * namei)
/* If we have an execname, record it. */
if (execname != NULL) {
if (procs[pid].execname == NULL)
procs[pid].execname = strdup(execname, M_TSLOGUSER);
if (procs[pid].execname != NULL)
free(procs[pid].execname, M_TSLOGUSER);
procs[pid].execname = strdup(execname, M_TSLOGUSER);
return;
}