1833017 Members
2096 Online
110048 Solutions
New Discussion

Re: Cntrl-C problem

 
Thomas Schler_1
Trusted Contributor

Cntrl-C problem

In my .profile, I want to open a dtterm with a running 'tail -f ...' in it, e.g.

% cat .profile
DT=${DT-""}
if [ ! "$DT" ] ; then
eval ` tset -s -Q `
stty erase "^H" kill "^U" intr "^C" eof "^D"
stty hupcl ixon ixoff
fi
dtterm -e nice tail -f /var/adm/syslog/syslog.log &

This works, but when I have to press Ctrl-C the dtterm with the running 'tail -f
...' is closed. That's due to setting intr to "^C".

How do I manage to have an running "tail -f" - dtterm although I press Ctrl-C?
no users -- no problems
4 REPLIES 4
Peter Kloetgen
Esteemed Contributor

Re: Cntrl-C problem

Hi Thomas,

you can trap signals sent to processes:

trap 'action' signals_to_trap

this "catches" the signals and they don't reach the process.

example:

trap '' 2

ctrl-c sends the signal interrupt, which has the signal number 2. So the signal doesn't reach the process. The only signal which cannot be catched is the signal 9 (kill). For information about which signal has which code number use:

kill -l

--> shows you the defined signals with code numbers


Allways stay on the bright side of life!

Peter
I'm learning here as well as helping
Ravi_8
Honored Contributor

Re: Cntrl-C problem

Hi,

the command 'nohup' before tail -f ........
may help you
never give up
S.K. Chan
Honored Contributor

Re: Cntrl-C problem

You would do something like this ..
#!/usr/bin/sh
trap $SHELL 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
tail -f /tmp/filelog
S.K. Chan
Honored Contributor

Re: Cntrl-C problem

I'm sorry .. too fast ..
From previous posting ..

Execute the script by entering the 'dtterm -e file_name' command.