From 989ca201e425e33aba8b51b9beb42158cc1b7ee5 Mon Sep 17 00:00:00 2001 From: Sergey Popov Date: Mon, 19 Dec 2011 10:07:48 +0400 Subject: [PATCH] lock LPT control circuit when receiving SIGTERM --- yasnd.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/yasnd.c b/yasnd.c index 5324706..964459f 100644 --- a/yasnd.c +++ b/yasnd.c @@ -139,6 +139,22 @@ void check_host(int num,host_decl* host) host->helper_pid=pid; } +/* + Function, that turn on first LPT port pin and turn off others. + This is needed to lock LPT control circuit, when + management computer is rebooted +*/ +void lpt_lock() +{ + if (ioperm (lpt_port, 3, 1)) + { + log_event("Error: LPT port access error"); + exit(EXIT_FAILURE); + } + // Lock circuit + outb (1, lpt_port); +} + /* Function, that turn on only one LPT port pin, defined by it argument, wait a second, and turn off all pins. That is enough to reset specified host. @@ -248,6 +264,9 @@ void signal_handler(int signum) if (signum==SIGTERM) { log_event("SIGTERM captured, daemon stopping"); + // block LPT control circuit + if (lpt_enable) + lpt_lock(); // close log decriptor closelog(); // free resources