Hi,

execline's trap doesn't seem to work in master. Consider the following
script:


#!/bin/execlineb -P

/home/belka/Projects/execline/trap {
  default {
        echo "Caught"
  }
}
sh -c "while :; do echo $$; sleep 1; done"


Sending signals to the trap process does nothing. If I revert
9d55d49dad0f4cb90e6ff2f9b1c3bc46a6fcf05f, trap works as expected. After
some debugging I think that the pids array in trap.c contains garbage
since it isn't initialized statically anymore (see the attached patch).

Best regards
Eugen
>From 3b800dae5ac017abfbf9f47b4c5ba3d0137f4b44 Mon Sep 17 00:00:00 2001
From: Eugen Wissner <[email protected]>
Date: Mon, 27 Mar 2023 21:21:42 +0200
Subject: [PATCH] Initialize pids in the trap main function

---
 src/execline/trap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/execline/trap.c b/src/execline/trap.c
index 52541ca..b409d77 100644
--- a/src/execline/trap.c
+++ b/src/execline/trap.c
@@ -45,7 +45,7 @@ static inline void trap_action (unsigned int i, char const 
*const *envp, size_t
 
 int main (int argc, char const **argv, char const *const *envp)
 {
-  pid_t pids[SKALIBS_NSIG + 1] ;
+  pid_t pids[SKALIBS_NSIG + 1] = { 0 } ;
   char const *const *argvs[SKALIBS_NSIG] = { 0 } ;
   size_t envlen = env_len(envp) ;
   iopause_fd x = { .events = IOPAUSE_READ } ;
-- 
2.35.7

Reply via email to