chiark / gitweb /
[PATCH] close the syslog
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>
Tue, 19 Oct 2004 01:15:10 +0000 (18:15 -0700)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 05:02:45 +0000 (22:02 -0700)
Seems that we never closed the opened syslog.
Here is a patch to do this in all our binaries.

logging.h
udev.c
udevd.c
udevinfo.c
udevsend.c
wait_for_sysfs.c

index 40c342c3ab0c04c7b2690c1e34548f06c49ee0ee..30f52c84ce6969eda5b0fb54c1a2c4151389c802 100644 (file)
--- a/logging.h
+++ b/logging.h
@@ -27,7 +27,8 @@
 #define info(format, arg...)           do { } while (0)
 #define dbg(format, arg...)            do { } while (0)
 #define dbg_parse(format, arg...)      do { } while (0)
-#define init_logging(foo)              do { } while (0)
+#define logging_init(foo)              do { } while (0)
+#define logging_close(foo)             do { } while (0)
 
 #ifdef LOG
 #include <stdarg.h>
@@ -65,13 +66,19 @@ extern void log_message(int level, const char *format, ...)
 /* each program that uses syslog must declare this variable somewhere */
 extern unsigned char logname[LOGNAME_SIZE];
 
-#undef init_logging
-static inline void init_logging(char *program_name)
+#undef logging_init
+static inline void logging_init(char *program_name)
 {
        snprintf(logname, LOGNAME_SIZE,"%s[%d]", program_name, getpid());
        openlog(logname, 0, LOG_DAEMON);
 }
 
+#undef logging_close
+static inline void logging_close(void)
+{
+       closelog();
+}
+
 #endif /* LOG */
 
 #endif
diff --git a/udev.c b/udev.c
index b4b08b335b8810d103509834eb0bfa32013e2391..10a937e4724f54bc69d609960b8799916f7dc182 100644 (file)
--- a/udev.c
+++ b/udev.c
@@ -122,7 +122,7 @@ int main(int argc, char *argv[], char *envp[])
        main_argv = argv;
        main_envp = envp;
 
-       init_logging("udev");
+       logging_init("udev");
 
        udev_init_config();
 
@@ -203,5 +203,6 @@ int main(int argc, char *argv[], char *envp[])
        udevdb_exit();
 
 exit:
+       logging_close();
        return retval;
 }
diff --git a/udevd.c b/udevd.c
index 811f62243eb98473d6691624dadcb2dfe67b235e..421c25a6e8df7fcdf8eb9ba31e0730bd1ba9f06a 100644 (file)
--- a/udevd.c
+++ b/udevd.c
@@ -150,7 +150,7 @@ static void udev_run(struct hotplug_msg *msg)
                /* child */
                execle(udev_bin, "udev", msg->subsystem, NULL, env);
                dbg("exec of child failed");
-               exit(1);
+               _exit(1);
                break;
        case -1:
                dbg("fork of child failed");
@@ -403,7 +403,7 @@ int main(int argc, char *argv[])
        struct sigaction act;
        fd_set readfds;
 
-       init_logging("udevd");
+       logging_init("udevd");
        dbg("version %s", UDEV_VERSION);
 
        if (getuid() != 0) {
@@ -549,5 +549,6 @@ int main(int argc, char *argv[])
        }
 exit:
        close(ssock);
+       logging_close();
        exit(1);
 }
index 8329fe7d06dd51681583b7af937f2c07c30121dd..763cfd139f76636286a9b76a8b41ec7ebca1a4d6 100644 (file)
@@ -447,18 +447,18 @@ help:
 
 int main(int argc, char *argv[], char *envp[])
 {
-       int retval;
+       int rc = 0;
 
        main_argv = argv;
        main_argc = argc;
 
-       init_logging("udevinfo");
+       logging_init("udevinfo");
 
        /* initialize our configuration */
        udev_init_config();
 
-       retval = process_options();
-       if (retval != 0)
-               exit(1);
-       exit(0);
+       rc = process_options();
+
+       logging_close();
+       exit(rc);
 }
index 23ba1a1b000b206953d95514fc7ab94423486ac7..883181c1b69dfe496677c942ac483d7a67c404ce 100644 (file)
@@ -123,7 +123,7 @@ int main(int argc, char* argv[])
        socklen_t addrlen;
        int started_daemon = 0;
 
-       init_logging("udevsend");
+       logging_init("udevsend");
        dbg("version %s", UDEV_VERSION);
 
        subsystem = get_subsystem(argv[1]);
@@ -215,5 +215,7 @@ exit:
        if (sock != -1)
                close(sock);
 
+       logging_close();
+
        return retval;
 }
index 1d7044c61f30e2adb73a71c70d375e669263ab78..37de02261d19627da27bd69c50de63323f58ad4e 100644 (file)
@@ -392,7 +392,7 @@ int main(int argc, char *argv[], char *envp[])
        int rc = 0;
        const char *error = NULL;
 
-       init_logging("wait_for_sysfs");
+       logging_init("wait_for_sysfs");
 
        if (argc != 2) {
                dbg("error: subsystem");
@@ -475,5 +475,6 @@ exit:
                dbg("result: waiting for sysfs successful '%s'", devpath);
        }
 
+       logging_close();
        exit(rc);
 }