Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disabling CTRL C in a Borne Shell

Status
Not open for further replies.

Mysterious

Technical User
Feb 28, 2000
1
SG
Hi! Wondering what are the ways to disable the<br>

CTRL-C combination in a Borne Shell!<br>

<br>

Thanks in advance!
 
Use the &quot;trap&quot; shell built-in command. eg, type the following at your shell prompt:<br>
<FONT FACE=monospace><br>
trap 'echo &quot;Ctrl-C was pressed&quot;' 2<br>
</font><br>
Now, whenever you press Ctrl-C, the message will be echoed.<br>
<br>
WARNING: This is not specific to pressing Ctrl-C. It is specific to whatever your interrupt key is set to. Type &quot;<FONT FACE=monospace>stty -a</font>&quot; and see what &quot;intr&quot; is set to. It may be ^C, it may not, but I'm assuming yours is :)<br>
<br>
You can use &quot;trap&quot; to check for any signal, and act accordingly. To set it permanently, put it into your .profile. It may also be inserted into a shell script that you are running.<br>
<br>
For more details, &quot;<FONT FACE=monospace>man sh</font>&quot; and search for &quot;trap&quot;.<br>
<br>
HTH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top