1825776 Members
2013 Online
109687 Solutions
New Discussion

Trap signal

 
Ngoh Chean Siung
Super Advisor

Trap signal

Hi,

For /etc/profile, there is a line called trap. To enable, put as trap 1 2 3. To disable, put as trap "" 1 2 3.

Questions:
1) How about trap : 1 2 3?
2) What I know is signal 1 for hang up, 2 for interrupt and 3 for quit. How to know which keys refer to which signal? I know ctrl+bckspace is signal 2 and ctrl+\ is signal 3.
3) Any reference about trap signal?

regards.

3 REPLIES 3
Franky_1
Respected Contributor

Re: Trap signal

Hi,

kill -l will give you the different signals

HTH

Franky
Don't worry be happy
Ngoh Chean Siung
Super Advisor

Re: Trap signal

Hi,

What is the signal for Delete button?

regards.
Muthukumar_5
Honored Contributor

Re: Trap signal

If we use trap "" 1 2 3 means, after trapping the SIGHUP, SIGINT, SIGQUIT signals, it wouldn't do nothing. you can test it a shell as,
#!/usr/bin/ksh

test1()
{
echo "Got signal "
echo "bye to shell"
}
trap "test1" 1 2 3
exit 0

Check with kill -1 pid of shell program or -2 or with -3

We can not use : with the trap

trap is used as ,
trap [arg] [sig ...]
If arg is the null string, this signal is ignored by the shell and by the commands it invokes.

To get the default action of trap in shell as,
#trap
trap -- 'echo '\''logout root'\' EXIT
If you give EXIT signal it will show the message.

References:
We can know the trap using man ksh page, man stty man pages.

We can know the signal controls with stty (terminal I/O options) as,
# stty -a or #stty

Use the csh shell to use delete as like linux.

Regards,
Muthukumar.
Easy to suggest when don't know about the problem!