[PLUG] Bash 'trap' command doesnt execute on SIGUSR1

Mayuresh mayuresh at acm.org
Mon Feb 7 16:23:36 IST 2011


On Mon, Feb 07, 2011 at 02:34:20AM -0800, अमेय साठे wrote:
> Hi,
> In the following bash code snippet; my main aim is to throw a string 'Unhandled exception occurred' using trap command. The command should capture 'exit 30' command. But; it is unable to do so.
> trap  'echo " Unhandled condition occurred "' SIGUSR1
> testdir()
> {
> dir="$@"
> if  [ ! -d $dir ]
>     then
> case "$dir" in
>   "/tmp/logdir" ) mkdir $dir ;;
>   "$HOME/s3sync" ) echo "s3sync is not installed." ;;
>   * ) echo "In function ${FUNCNAME} at $LINENO " 
>           exit 30;;  

Why don't you place the error message here at exit itself? (or put the
message in a function and call it from here?)

traps are for capturing asynchronous events received by the process.

> esac
> fi
> }




More information about the Plug-mail mailing list