2
0
mirror of https://github.com/xcat2/xcat-dep.git synced 2024-11-27 03:39:11 +00:00
xcat-dep/ipmitool/ipmitool-1.8.15-signal.patch
chenglch dc52c082d7 Handle TERM and HUP signal in ipmitool
- Reset tty setting after receiving INT,HUP and TERM signal.
- Add TERM, HUP handler to close the connection session to the BMC

Close-issue: #9
2016-08-10 02:51:31 -04:00

55 lines
2.0 KiB
Diff

diff -uNr ipmitool-1.8.15/include/ipmitool/ipmi_sol.h ipmitool-1.8.15-signal/include/ipmitool/ipmi_sol.h
--- ipmitool-1.8.15/include/ipmitool/ipmi_sol.h 2014-03-28 08:36:21.000000000 -0400
+++ ipmitool-1.8.15-signal/include/ipmitool/ipmi_sol.h 2016-08-09 22:35:14.030029120 -0400
@@ -103,6 +103,6 @@
int ipmi_get_sol_info(struct ipmi_intf * intf,
uint8_t channel,
struct sol_config_parameters * params);
-
+void leave_raw_mode(void);
#endif /* IPMI_SOL_H */
diff -uNr ipmitool-1.8.15/lib/ipmi_main.c ipmitool-1.8.15-signal/lib/ipmi_main.c
--- ipmitool-1.8.15/lib/ipmi_main.c 2014-08-11 13:37:37.000000000 -0400
+++ ipmitool-1.8.15-signal/lib/ipmi_main.c 2016-08-10 01:13:38.350442782 -0400
@@ -258,20 +258,22 @@
if (cmdlist != NULL)
ipmi_cmd_print(cmdlist);
}
-/* ipmi_catch_sigint - Handle the interrupt signal (Ctrl-C), close the
- * interface, and exit ipmitool with error (-1)
+/* ipmi_catch_sig - Handle the interrupt signal (Ctrl-C),TERM signal,
+ * and HUP signal. Close the interface, and exit
+ * ipmitool with error (-1)
*
- * This insures that the IOL session gets freed
- * for other callers.
+ * This insures that the IOL session gets freed
+ * for other callers.
*
* returns -1
*/
-void ipmi_catch_sigint()
+void ipmi_catch_sig(const int sig)
{
if (ipmi_main_intf != NULL) {
- printf("\nSIGN INT: Close Interface %s\n",ipmi_main_intf->desc);
+ printf("\nSIGN %s: Close Interface %s\n",strsignal(sig), ipmi_main_intf->desc);
ipmi_main_intf->close(ipmi_main_intf);
}
+ leave_raw_mode();
exit(-1);
}
@@ -391,7 +393,9 @@
/* save program name */
progname = strrchr(argv[0], '/');
progname = ((progname == NULL) ? argv[0] : progname+1);
- signal(SIGINT, ipmi_catch_sigint);
+ signal(SIGINT, ipmi_catch_sig);
+ signal(SIGTERM, ipmi_catch_sig);
+ signal(SIGHUP, ipmi_catch_sig);
while ((argflag = getopt(argc, (char **)argv, OPTION_STRING)) != -1)
{