LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   prevent Ctrl-C while "~/.bashrc" is running (https://www.linuxquestions.org/questions/linux-software-2/prevent-ctrl-c-while-%7E-bashrc-is-running-744864/)

lothario 08-03-2009 05:02 PM

prevent Ctrl-C while "~/.bashrc" is running
 
I have setup the "~/.bashrc" for a user and it is working fine.
It takes about 5 to 10 seconds to finish running because everytime the user logs in, it needs to fetch and process some data from a remote server.

So the user knows that he has to wait for about 5 to 10 seconds.

How can I prevent the user from doing Ctrl-C on the keyboard to abort this "~/.bashrc" prematurely?

tcomputerchip 08-03-2009 06:10 PM

Quote:

Originally Posted by lothario (Post 3630128)
I have setup the "~/.bashrc" for a user and it is working fine.
It takes about 5 to 10 seconds to finish running because everytime the user logs in, it needs to fetch and process some data from a remote server.

So the user knows that he has to wait for about 5 to 10 seconds.

How can I prevent the user from doing Ctrl-C on the keyboard to abort this "~/.bashrc" prematurely?


One way might be to remap Ctrl key to something else like spacebar before the script starts or at the top of your script. Then remap it back to what ever was the default...

I would start by looking at the Xdefaults file or the xmodmap command.

I think xmodmap can be run before the script and after the script, in theory you could remap all keys to spacebar, then load the default xmodmap when done.

This is how I setup kiosks.

-t

chrism01 08-03-2009 08:54 PM

Here are some simpler solns:
http://nixcraft.com/shell-scripting/...-c-ctrl-z.html
http://forums13.itrc.hp.com/service/...06208+28353475

lothario 08-04-2009 01:11 AM

Quote:

Originally Posted by chrism01 (Post 3630273)

This one worked for me. Thanks.

Now that I have Ctrl-C taken care of.
Are there any other such gotchas that I should handle?
So that "~/.bashrc" does not get interrupted.

chrism01 08-04-2009 07:41 PM

As per those links, you can trap a lot of stuff (pretty much all the signals for a start), so http://en.wikipedia.org/wiki/Category:Unix_signals and re-read the links.
:)


All times are GMT -5. The time now is 01:26 PM.