Operating System - HP-UX
1832978 Members
2488 Online
110048 Solutions
New Discussion

Re: Rejecting Control C from Users

 
SOLVED
Go to solution
David Land
Frequent Advisor

Rejecting Control C from Users

Is there a way to prevent a user from being able to perform a ^C (Control C) to get to a command line?

I am in the process of trying to lock down some user accounts from being able to ^C out of a menu I have created.
4 REPLIES 4
Pete Randall
Outstanding Contributor
Solution

Re: Rejecting Control C from Users

You can do it like /etc/profile does:

trap "" 1 2 3 # ignore HUP, INT, QUIT now.


Pete

Pete
Tony Scully_2
Valued Contributor

Re: Rejecting Control C from Users

Or trap the ctrlC and do an exit, so it drops them right out.
You CAN do that on HP
Bill Hassell
Honored Contributor

Re: Rejecting Control C from Users

Completely ignoring all the signals (especially signal 1, called SIGHUP) can leave processes hanging. It is best to detect a hangup or a CTRL-C (and others) and take an action, usually by exiting:

trap "exit" 1 2 3 15

The trap statement says that CTRL-C or a broken connection, etc, will simply exit and if your menu script is the user's login shell, they will be logged out. The trap technique is used in HP's standard /etc/profile.


Bill Hassell, sysadmin
David Land
Frequent Advisor

Re: Rejecting Control C from Users

That has helped me out. Thanks everyone. Thanks Bill, I will change the trap statement to reflect the 'exit' command.