help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Different handling of "trap" in bash 4.4.20(1)-release (x86_64-pc-linux-


From: MESSNER Andreas
Subject: Different handling of "trap" in bash 4.4.20(1)-release (x86_64-pc-linux-gnu) and bash version 5.2.15(1)-release (x86_64-aeos5-linux-gnu)
Date: Wed, 27 Sep 2023 09:08:15 +0000

Classified as: {OPEN}

Hello,

I have a question concerning "trap"  handling in bash
Script for testing:
#/bin/bash

function cleanup ()
{
    echo "Executing cleanup"

    # trying to kill non-existing process
    killall doesnotexist >/dev/null 2>&1
    killall doesnotexist >/dev/null 2>&1

    echo "Leaving cleanup"
}
trap cleanup INT CHLD

echo "Calling cleanup"
cleanup
echo "Back from cleanup"

sleep 1

Executing the script in bash 4.4.20(1) shows the following result:
Calling cleanup
Executing cleanup
Leaving cleanup
Back from cleanup

Executing the script in bash 5.2.15(1) shows the following result:
Calling cleanup
Executing cleanup
Executing cleanup
Leaving cleanup
Executing cleanup
Leaving cleanup
Executing cleanup
Leaving cleanup
Executing cleanup
Leaving cleanup
Leaving cleanup
Back from cleanup
Executing cleanup
Leaving cleanup
Executing cleanup
Leaving cleanup
Executing cleanup
Leaving cleanup
Executing cleanup
Leaving cleanup
Executing cleanup
Leaving cleanup
Executing cleanup
Leaving cleanup
Executing cleanup
Leaving cleanup

I know it's an easy fix, but I'm curious as to what's causing the different 
behavior

Thank you for any replies
Andreas



{OPEN}

Thales is in the process of carving out its Transportation activity (GTS) from 
other Thales' activities. In order to prepare this internal restructuring, a 
new e-mail address has been adopted and your GTS contacts now use 
urbanandmainlines.com. Please note that their Thales e-mail address remains 
also valid.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]