Repair setproctitle (libbsd)

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
This commit is contained in:
Georg Pfuetzenreuter 2022-04-22 08:07:45 +00:00
parent 2bec10927f
commit b9454e9f1c
Signed by: Georg
GPG Key ID: 1ED2F138E7E6FF57

View File

@ -40,6 +40,8 @@
#include <syslog.h>
#include <malloc.h>
#include <sys/file.h>
#include <sys/types.h>
#include <bsd/unistd.h>
#include "daemon.h"
@ -212,13 +214,14 @@ static void setTitle(void) {
for (size_t i = 0; i < services.len; ++i) {
if (services.ptr[i].state == Start) started++;
}
// throws warning about missing setproctitle_init, even if linked against libbsd-ctor
//setproctitle("%zu/%zu services", started, services.len);
// this works now, but breaks syslog identifier
//setproctitle("%zu/%zu cats", started, services.len);
}
int main(int argc, char *argv[]) {
int main(int argc, char *argv[], char *envp[]) {
int error;
openlog(getprogname(), LOG_NDELAY | LOG_PID | LOG_PERROR, LOG_DAEMON);
syslog(LOG_NOTICE, "Starting %s ...", getprogname());
bool daemonize = true;
setAdd(&stopExits, EX_USAGE);
@ -276,6 +279,8 @@ int main(int argc, char *argv[]) {
setgid(serviceGID);
setuid(serviceUID);
setproctitle_init(argc, argv, envp);
int len = asprintf(&serviceEnviron[USER], "USER=%s", user->pw_name);
if (len < 0) err(EX_OSERR, "asprintf");
@ -465,8 +470,7 @@ shutdown:
close(fifo);
unlink(fifoPath);
// same as with previous occurance
//setproctitle("stopping");
setproctitle("stopping");
size_t count = 0;
for (size_t i = 0; i < services.len; ++i) {
serviceStop(&services.ptr[i]);