I just had a thought- Is it possible to move grabbing the SIGINT from uloop_run( ) to uloop_init( ), with the possibility to execute a uloop_call_this_to_end_loop() function which sets the uloop_cancelled variable? (this could then be called from a signal handler without exposing the uloop_cancelled variable).
The signal handler can be hooked by default by uloop to emulate existing behaviour if that is so desired, but by taking things out of uloop_run( ) it is possible to grab back SIGINT in a nice way. Let me know, I can rework the patches to get this to work again, but I think its wiser to discuss this first, then implement it. Kind regards, Michel Stam -----Original Message----- From: openwrt-devel [mailto:openwrt-devel-boun...@lists.openwrt.org] On Behalf Of Stam, Michel [FINT] Sent: Tuesday, October 07, 2014 17:08 PM To: openwrt-devel@lists.openwrt.org; John Crispin Subject: Re: [OpenWrt-Devel] [PATCH procd] Add ctrlaltdel handler to procd Hello John, I saw you had reworked my ctrl-alt-del patch for procd. Ok, but unfortunately, it does not work for me. What happens; when I press ctrl-alt-del on the unit, I get an "attempting to kill init" panic. This happens because the procd process exits. The kernel does not like its init process dying. If I look in procd.c, I see: uloop_run(); uloop_done(); if (getpid() == 1) { procd_shutdown(RB_AUTOBOOT); } procd_shutdown( ) is called, I see this on the console. But it indirectly fires off a runqueue which should be handled from the uloop_run( ) call. This takes care of running the shutdown scripts. But the uloop has already been cleaned up by uloop_done( ), because the uloop_run( ) was interrupted by the SIGINT. Thus this runqueue is never handled. Because of this, its rcdone( ) is never called (inittab.c), which should invoke procd_state_next( ), which then moves procd into killing the processes and calling the reboot( ) system call. It is important that procd does not exit before the reboot( ) system call is called thus remaining in the uloop_run( ) and letting the loop run its course, but without grabbing SIGINT back from libubox/uloop, I would have no idea how to fix this. My fix, by adding something to libubox to unhook SIGINT so the application can catch it was not pretty, but it did solve this problem. Another problem would be adding a process which grabs SIGINT back from uloop( ) but this sounds a bit hackish to me. Any suggestions? I have finished the /proc/cmdline patch, but I'm hanging on to it as testing my terminal fix is a tad difficult if I can't get the reboot working properly. Michel Stam -----Original Message----- From: Michel Stam [mailto:m.s...@fugro.nl] Sent: Thursday, October 02, 2014 14:51 PM To: openwrt-devel@lists.openwrt.org Cc: Stam, Michel [FINT] Subject: [PATCH procd] Add ctrlaltdel handler to procd Procd, up until now, did not support the ctrlaltdel handler. Thus, the system would immediately reboot upon the three-finger salute, and no shutdown scripts would be run. This patch adds the handler for the /etc/inittab entry, so that /sbin/reboot can be run and in turn the shutdown scripts can be invoked. Signed-off-by: Michel Stam <m.s...@fugro.nl> --- procd.c | 1 + signal.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/procd.c b/procd.c index ad80284..6ec7cd0 100644 --- a/procd.c +++ b/procd.c @@ -62,6 +62,7 @@ int main(int argc, char **argv) } } uloop_init(); + uloop_release_sigint(); procd_signal(); trigger_init(); if (getpid() != 1) diff --git a/signal.c b/signal.c index 74cabcb..6c00fd9 100644 --- a/signal.c +++ b/signal.c @@ -36,6 +36,7 @@ static void signal_shutdown(int signal, siginfo_t *siginfo, void *data) char *msg = NULL; switch(signal) { + case SIGINT: case SIGTERM: event = RB_AUTOBOOT; msg = "reboot"; @@ -91,4 +92,6 @@ void procd_signal(void) sigaction(SIGHUP, &sa_dummy, NULL); sigaction(SIGKILL, &sa_dummy, NULL); sigaction(SIGSTOP, &sa_dummy, NULL); + sigaction(SIGINT, &sa_shutdown, NULL); + reboot(RB_DISABLE_CAD); } -- 1.7.12.1 _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel