Sunday 17 January 2016

Bash shell script trap command example

#/bin/bash

#trace ctrl+c for kill a process
#trap handles seperately before terminating the process

function trap_handler()
{
        echo "trap_handler called  $$ $@"
        rm -f /tmp/input0.$$
        exit 1
}

trap trap_handler 2

echo "provide emp name"
read name

No comments:

Post a Comment