2 #include "alloc-util.h"
5 char *program_invocation_name = NULL;
6 char *program_invocation_short_name = NULL;
9 #include "musl_missing.h"
11 static void elogind_free_program_name(void) {
12 if (program_invocation_name)
13 program_invocation_name = mfree(program_invocation_name);
14 if (program_invocation_short_name)
15 program_invocation_short_name = mfree(program_invocation_short_name);
18 void elogind_set_program_name(const char* pcall) {
19 assert(pcall && pcall[0]);
21 if ( ( program_invocation_name
22 && strcmp(program_invocation_name, pcall))
23 || ( program_invocation_short_name
24 && strcmp(program_invocation_short_name, basename(pcall)) ) )
25 elogind_free_program_name();
27 if (NULL == program_invocation_name)
28 program_invocation_name = strdup(pcall);
29 if (NULL == program_invocation_short_name)
30 program_invocation_short_name = strdup(basename(pcall));
33 atexit(elogind_free_program_name);