diff --git blogctl.8 blogctl.8 index 93f29b4..cbbfc06 100644 --- blogctl.8 +++ blogctl.8 @@ -53,6 +53,14 @@ This let the daemon disconnect from system console. .TP .B reactivate Whereas this cause the daemon reconnect to system console. +.TP +.B final +Let rename the daemon an open log file +.I /var/log/boot.log +to the new name +.I /var/log/boot.old +as well as mask it own program name in the process table +with the @ character. .SH SEE ALSO .BR blogd (8), .BR systemd (1), diff --git blogd.c blogd.c index 9f322e9..0ca0f9e 100644 --- blogd.c +++ blogd.c @@ -221,7 +221,6 @@ static volatile pid_t pid = -1; static void flush_handler (void) attribute((noinline)); static void exit_handler (void) attribute((noinline)); -volatile char *arg0; /* * Now do the job @@ -230,6 +229,7 @@ int main(int argc, char *argv[]) { char ptsname[NAME_MAX+1]; const char *tty, *stt; + volatile char *arg0; struct console *c; struct termios o; struct winsize w; @@ -248,6 +248,7 @@ int main(int argc, char *argv[]) warn("could not tell system to show its status"); arg0 = (volatile char*)argv[0]; + remember_arg0(arg0); while ((arg = getopt(argc, argv, "f")) != -1) { switch (arg) { diff --git libconsole/console.c libconsole/console.c index b3a499b..89ae1e5 100644 --- libconsole/console.c +++ libconsole/console.c @@ -50,7 +50,17 @@ #endif int final = 0; -extern volatile char *arg0; +static volatile char *_arg0; + +/* + * Avoid trouble if linked with e.g. blogger as there + * is no external arg0 but linker on ppc64 and s390/x + * seems to expect this. + */ +void remember_arg0(volatile char *arg0) +{ + _arg0 = arg0; +} /* * Used to ignore some signals during epoll_pwait(2) or ppoll(2) @@ -1044,13 +1054,13 @@ static void socket_handler(int fd) enqry = ANSWER_ACK; safeout(fd, enqry, strlen(enqry)+1, SSIZE_MAX); - if (!final) { + if (!final && _arg0) { int ret; final = 1; - if (arg0[0] != '@') - arg0[0] = '@'; + if (_arg0[0] != '@') + _arg0[0] = '@'; ret = rename(BOOT_LOGFILE, BOOT_OLDLOGFILE); if (ret < 0) { diff --git libconsole/libconsole.h libconsole/libconsole.h index d14fda5..7151d16 100644 --- libconsole/libconsole.h +++ libconsole/libconsole.h @@ -122,6 +122,7 @@ extern int evmax; extern volatile sig_atomic_t signaled; extern volatile sig_atomic_t nsigsys; +extern void remember_arg0(volatile char *arg0); extern ssize_t safein (int fd, void *ptr, size_t s); extern void safeout (int fd, const void *ptr, size_t s, ssize_t max);