acpid: fix logging
authorSerj Kalichev <serj.kalichev@gmail.com>
Mon, 23 Feb 2015 14:26:47 +0000 (15:26 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Mon, 23 Feb 2015 14:26:47 +0000 (15:26 +0100)
Without this patch acpid can't log the events at all. Moreover it tries
to truncate log file every time.

Signed-off-by: Serj Kalichev <serj.kalichev@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
util-linux/acpid.c

index 38421c2d7f1cc15c621d2c2cff6384b97cf0f175..fc8151f6aa46634c99e067b8358f40cd9ad3db7e 100644 (file)
@@ -121,10 +121,8 @@ static void process_event(const char *event)
        char *handler = xasprintf("./%s", event);
        const char *args[] = { "run-parts", handler, NULL };
 
-       // debug info
-       if (option_mask32 & OPT_d) {
-               bb_error_msg("%s", event);
-       }
+       // log the event
+       bb_error_msg("%s", event);
 
        // spawn handler
        // N.B. run-parts would require scripts to have #!/bin/sh
@@ -256,7 +254,7 @@ int acpid_main(int argc UNUSED_PARAM, char **argv)
                /* No -d "Debug", we log to log file.
                 * This includes any output from children.
                 */
-               xmove_fd(xopen(opt_logfile, O_WRONLY | O_CREAT | O_TRUNC), STDOUT_FILENO);
+               xmove_fd(xopen(opt_logfile, O_WRONLY | O_CREAT | O_APPEND), STDOUT_FILENO);
                xdup2(STDOUT_FILENO, STDERR_FILENO);
                /* Also, acpid's messages (but not children) will go to syslog too */
                openlog(applet_name, LOG_PID, LOG_DAEMON);