Handling SIGCHLD

This forum is dedicated to advanced help and support :

Ask here your questions about advanced usage of Mageia. For example you may post here all your questions about network and automated installs, complex server configurations, kernel tuning, creating your own Mageia mirrors, and all tasks likely to be touchy even for skilled users.

Handling SIGCHLD

Postby gazeet » Feb 28th, '24, 13:59

I have several old bash scripts, that include traps for SIGCHLD. The intention was to catch failures or interrupts in user commands executed within these scripts, allowing the whole script to abort immediately. In Mageia 7 (5.10.46-desktop-1.mga7), for example, this seems to have had the intended effect. Now with kernel 6.5.13-desktop-6.mga9 it seems like SIGCHLD is generated even on normal terminations of child processes.

Reading the description it seems like this might be the expected posix behaviour (but it breaks this previous *simple* use of SigCHLD to try to capture user interrupts during a child process). While I can see how to solve this by elimintating the "trap" and recoding all the user programs that are executed within the scripts to ensure they return the proper exit codes I am curious to know why this behaviour changed with the newer kernels? Is there some kernel setting controlling this?
gazeet
 
Posts: 1
Joined: Feb 28th, '24, 13:38

Re: Handling SIGCHLD

Postby doktor5000 » Feb 28th, '24, 19:29

Might be helpful if you would add some actual examples, and some context information - like in what context are those bash scripts run, inside of an interactive shell or not ...
Also what have you configured regarding job control for your bash settings or in your scripts ?

See e.g. https://stackoverflow.com/questions/676 ... ap-sigchld
or also https://forums.raspberrypi.com/viewtopic.php?t=268860
And here from the bash maintainer: https://lists.gnu.org/archive/html/bug- ... 00065.html

On a related note, usually it should be enough to simply trap SIGINT (e.g. when a user presses Ctrl+C during runtime) in the main script, why do it for every child process ?
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18015
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany


Return to Advanced support

Who is online

Users browsing this forum: No registered users and 1 guest