From bdbe6e354a45b5c9406f934a1be3420ec39fddba Mon Sep 17 00:00:00 2001 From: Vincent-FK Date: Mon, 5 Apr 2021 17:32:43 +0200 Subject: [PATCH] removed fopencookie for redirecting logs in daemon mode because of (again) muslc incompatibility --- main.c | 5 +++++ to_log.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 404fe75..b81adb8 100644 --- a/main.c +++ b/main.c @@ -213,10 +213,15 @@ int main(int argc, char *argv[]) if (daemon) { /* Run as a background daemon, redirect all output to syslog */ + printf("Func %s, line %d\n", __func__, __LINE__); openlog("fkgpiod", LOG_PERROR | LOG_PID | LOG_NDELAY, LOG_DAEMON); + printf("Func %s, line %d\n", __func__, __LINE__); to_log(&stdout); + printf("Func %s, line %d\n", __func__, __LINE__); to_log(&stderr); + printf("Func %s, line %d\n", __func__, __LINE__); daemonize("/", PID_FILE); + printf("Func %s, line %d\n", __func__, __LINE__); } /* Initialize the uinput device */ diff --git a/to_log.c b/to_log.c index d4c0501..edfe625 100644 --- a/to_log.c +++ b/to_log.c @@ -81,5 +81,6 @@ static cookie_io_functions_t log_fns = { /* Redirect given file output descriptor to syslog */ void to_log(FILE **pfp) { - setvbuf(*pfp = fopencookie(NULL, "w", log_fns), NULL, _IOLBF, 0); + //setvbuf(*pfp = fopencookie(NULL, "w", log_fns), NULL, _IOLBF, 0); //not working with muslc + setvbuf(*pfp, NULL, _IOLBF, 0); }