Re: [Toybox] [PATCH] SIGHUP to init.c triggers inittab reload

2020-09-08 Thread Chris Sarra via Toybox
Thanks Rob, and no worries- I've been able to use the init.c for a few
months now, with only that patch. So hopefully cleanup won't be so bad! :)
+Chris


On Tue, Sep 1, 2020 at 11:16 PM Rob Landley  wrote:

> On 9/1/20 9:22 PM, Chris Sarra via Toybox wrote:
> > ---
> >  toys/pending/init.c | 25 -
> >  1 file changed, 24 insertions(+), 1 deletion(-)
>
> Applied, but this command is in pending. Caviar Emperor and all that...
>
>   https://github.com/landley/toybox/blob/master/toys/pending/README#L6
>
> (Yes, I should https://landley.net/toybox/cleanup.html all the pending
> stuff,
> alas this is still not my day job, doing what I can...)
>
> Thanks for the patch,
>
> Rob
>
___
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net


Re: [Toybox] [PATCH] SIGHUP to init.c triggers inittab reload

2020-09-02 Thread Rob Landley
On 9/1/20 9:22 PM, Chris Sarra via Toybox wrote:
> ---
>  toys/pending/init.c | 25 -
>  1 file changed, 24 insertions(+), 1 deletion(-)

Applied, but this command is in pending. Caviar Emperor and all that...

  https://github.com/landley/toybox/blob/master/toys/pending/README#L6

(Yes, I should https://landley.net/toybox/cleanup.html all the pending stuff,
alas this is still not my day job, doing what I can...)

Thanks for the patch,

Rob
___
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net


[Toybox] [PATCH] SIGHUP to init.c triggers inittab reload

2020-09-01 Thread Chris Sarra via Toybox
---
 toys/pending/init.c | 25 -
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/toys/pending/init.c b/toys/pending/init.c
index 64b61481..b147911f 100644
--- a/toys/pending/init.c
+++ b/toys/pending/init.c
@@ -188,6 +188,25 @@ static void inittab_parsing(void)
   }
 }
 
+static void reload_inittab(void)
+{
+  // Remove all inactive actions, then reload /etc/inittab
+  struct action_list_seed **y;
+  y = _list_pointer;
+  while (*y) {
+if (!(*y)->pid) {
+  struct action_list_seed *x = *y;
+  free(x->terminal_name);
+  free(x->command);
+  *y = (*y)->next;
+  free(x);
+  continue;
+}
+y = &(*y)->next;
+  }
+  inittab_parsing();
+}
+
 static void run_command(char *command)
 {
   char *final_command[128];
@@ -405,7 +424,7 @@ static void restart_init_handler(int sig_no)
 static void catch_signal(int sig_no)
 {
   caught_signal = sig_no;
-  error_msg("signal seen");
+  error_msg("signal seen: %d", sig_no);
 }
 
 static void pause_handler(int sig_no)
@@ -439,6 +458,10 @@ static int check_if_pending_signals(void)
 caught_signal = 0;
 signal_caught = 1;
 if (sig == SIGINT) run_action_from_list(CTRLALTDEL);
+else if (sig == SIGHUP) {
+  error_msg("reloading inittab");
+  reload_inittab();
+}
   }
 }
 
-- 
2.28.0.402.g5ffc5be6b7-goog

___
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net