[PATCH 2/2] wpa_supplicant: Allow re-open of log files with SIGHUP

Ben Greear greearb
Wed Nov 17 16:58:06 PST 2010


With this, one can cause wpa_supplicant log files to
roll:

mv log.txt log.txt.old
kill -HUP <wpa_supplicant-pid>

Signed-off-by: Ben Greear <greearb at candelatech.com>
---
:100644 100644 c0aa59c... 00e4593... M	wpa_supplicant/main.c
:100644 100644 8bbb73f... 932c918... M	wpa_supplicant/wpa_supplicant.c
 wpa_supplicant/main.c           |    9 ++++++++-
 wpa_supplicant/wpa_supplicant.c |    5 +++++
 2 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/wpa_supplicant/main.c b/wpa_supplicant/main.c
index c0aa59c..00e4593 100644
--- a/wpa_supplicant/main.c
+++ b/wpa_supplicant/main.c
@@ -23,6 +23,7 @@
 
 extern struct wpa_driver_ops *wpa_drivers[];
 
+static struct wpa_params params;
 
 static void usage(void)
 {
@@ -120,13 +121,19 @@ static void wpa_supplicant_fd_workaround(void)
 #endif /* __linux__ */
 }
 
+void handle_sighup(int sig, void *signal_ctx)
+{
+	wpa_printf(MSG_INFO, "SIGHUP received - reopening log-file");
+	wpa_debug_close_file();
+	wpa_debug_open_file(params.wpa_debug_file_path);
+	wpa_printf(MSG_INFO, "SIGHUP received - reopened log-file");
+}
 
 int main(int argc, char *argv[])
 {
 	int c, i;
 	struct wpa_interface *ifaces, *iface;
 	int iface_count, exitcode = -1;
-	struct wpa_params params;
 	struct wpa_global *global;
 
 	if (os_program_init())
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 8bbb73f..932c918 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -121,6 +121,7 @@ extern int wpa_debug_level;
 extern int wpa_debug_show_keys;
 extern int wpa_debug_timestamp;
 extern struct wpa_driver_ops *wpa_drivers[];
+extern void handle_sighup(int sig, void *signal_ctx); /* main.c */
 
 /* Configure default/group WEP keys for static WEP */
 int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
@@ -2420,6 +2421,10 @@ struct wpa_global * wpa_supplicant_init(struct wpa_params *params)
 		}
 	}
 
+#ifndef CONFIG_NATIVE_WINDOWS
+	eloop_register_signal(SIGHUP, handle_sighup, NULL);
+#endif /* CONFIG_NATIVE_WINDOWS */
+
 	return global;
 }
 
-- 
1.7.2.3




More information about the Hostap mailing list