Hi, all! I am trying to make init program on picolisp (yes, I am that crazy). When Ctrl+Alt+Del is pressed, SIGTERM is sended to init process, so I want to handle this signal.
I made patch which add new global *Term. When it is defined and retures non-NIL, standard handler is not processed. I think it is good idea to have such handler. Regards, Constantine diff --git a/src/glob.l b/src/glob.l index 7862141..f97697c 100644 --- a/src/glob.l +++ b/src/glob.l @@ -139,6 +139,7 @@ ($Winch "*Winch" $Nil) ($TStp1 "*TStp1" $Nil) ($TStp2 "*TStp2" $Nil) + ($Term "*Term" $Nil) ($Up "\^" $Nil) ($Err "*Err" $Nil) ($Msg "*Msg" $Nil) diff --git a/src/main.l b/src/main.l index 9add9be..bac9eef 100644 --- a/src/main.l +++ b/src/main.l @@ -213,22 +213,25 @@ (execAt (val $TStp2)) # Run 'TStp2' (rlSigEnd) ) ((val (setq P (ofs $Signal SIGTERM))) - (let - (Cld (val $Child) # Iterate children - <Cld (ofs Cld (* (val $Children) (child T))) - Flg NO ) - (until (== Cld <Cld) - (let Cld: (child Cld) - (when - (and - (Cld: pid) - (=0 (kill @ (val SIGTERM Sig))) ) - (setq Flg YES) ) ) - (setq Cld (ofs Cld (child T))) ) - (? Flg) - (set $Signal 0) - (rlSigBeg) - (bye 0) ) ) ) + (set P (dec @)) + (set $Signal (dec (val $Signal))) + (when (nil? (run (val $Term))) + (let + (Cld (val $Child) # Iterate children + <Cld (ofs Cld (* (val $Children) (child T))) + Flg NO ) + (until (== Cld <Cld) + (let Cld: (child Cld) + (when + (and + (Cld: pid) + (=0 (kill @ (val SIGTERM Sig))) ) + (setq Flg YES) ) ) + (setq Cld (ofs Cld (child T))) ) + (? Flg) + (set $Signal 0) + (rlSigBeg) + (bye 0) ) ) ) ) (? (=0 (val $Signal))) ) ) (set $Protect 0) ) ) -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe