Solved

Disable "Ctrl+C"

Posted on 2006-06-19
3
379 Views
Last Modified: 2010-04-21
Dear All,

Can I prevent the user from terminating the program by pressing "Ctrl+C" after running the script developed by me?

Please advise.
I am using Sun Solaris 8 & ksh.

Thanks.
0
Comment
Question by:iecu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 21

Accepted Solution

by:
tfewster earned 125 total points
ID: 16940132
Yes, using the shell built-in comand `trap`, e.g.
trap 'echo "Ctrl-C disabled" ' 0 1 2 3

For more examples, please see
http://www.experts-exchange.com/Developer/Operating_Systems/Solaris/Q_20311700.html
http://www.experts-exchange.com/Programming/Programming_Platforms/Unix_Programming/Q_10074403.html


0
 
LVL 48

Expert Comment

by:Tintin
ID: 16956566
or to disable completely, add

stty intr ''

in the user's .profile

0
 
LVL 48

Expert Comment

by:Tintin
ID: 16997233
trap 'echo "Ctrl-C disabled" ' 0 1 2 3

is more accurately written

trap 'echo "SIGINT is trapped, which may or may not be Ctrl-C"' 2
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Suggested Courses

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question