C Board  

Go Back   C Board > Platform Specific Boards > Linux Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 01-15-2004, 08:31 AM   #1
Registered User
 
Join Date: Dec 2003
Posts: 6
Question How to prevent exiting from running program

Hi all...

I am developing a C programme for database management, and I need to make it unclosable unless the quit button is clicked. So I shall be realy thankful if anybody could help me out and tell me how to do it.
I want to isable everything right from Ctrl+z to suspend to Ctrl+c for exit and Ctrl+Alt+Delete if possibal at all.

Thanks in advance....
scorpio_IITR is offline   Reply With Quote
Old 01-15-2004, 09:47 AM   #2
still a n00b
 
Jaguar's Avatar
 
Join Date: Jun 2002
Posts: 187
>> and I need to make it unclosable unless the quit button is clicked
for GUI, don't know

following for console
Code:
#include <signal.h>

signal(SIGINT,SIG_IGN); /* disable ctrl-C */
signal(SIGQUIT,SIG_IGN); /* disable ctrl-\ */
signal(SIGTSTP,SIG_IGN); /* disable ctrl-Z */
__________________
slackware 10.0; kernel 2.6.7
gcc 3.4.0; glibc 2.3.2; vim editor
migrating to freebsd 5.4
Jaguar is offline   Reply With Quote
Old 01-15-2004, 11:26 AM   #3
Registered User
 
Join Date: Jan 2004
Posts: 6
Re: How to prevent exiting from running program

Quote:
Originally posted by scorpio_IITR
I want to isable everything right from Ctrl+z to suspend to Ctrl+c for exit and Ctrl+Alt+Delete if possibal at all.
all you can do is catch a bunch of 'allowed' signals:

stopping (sort of ):
SIGINT (Ctrl-C)
SIGABRT(Ctrl-\)
SIGTERM
SIGHUP

pausing:
SIGSTP (Ctrl-Z)

you can't catch SIGKILL (kill -9) or SIGSTOP, as they're handled by the kernel; Ctrl+Alt+Del is a different story: in console mode, init snatches it, in X usually the desktop manager does. either way, you probably won't see it (and well you shouldn't - you can't handle the reset button either )
abc_coder is offline   Reply With Quote
Old 01-16-2004, 03:49 AM   #4
still a n00b
 
Jaguar's Avatar
 
Join Date: Jun 2002
Posts: 187
Re: Re: How to prevent exiting from running program

>> SIGABRT(Ctrl-\)
?*?*? SIGQUIT

>> SIGSTP (Ctrl-Z)
SIGTSTP
__________________
slackware 10.0; kernel 2.6.7
gcc 3.4.0; glibc 2.3.2; vim editor
migrating to freebsd 5.4
Jaguar is offline   Reply With Quote
Old 01-16-2004, 04:12 PM   #5
Registered User
 
Join Date: Jan 2004
Posts: 6
Re: Re: Re: How to prevent exiting from running program

Quote:
Originally posted by Jaguar
>> SIGABRT(Ctrl-\)
?*?*? SIGQUIT

>> SIGSTP (Ctrl-Z)
SIGTSTP
yeah, SIGTSTP (sorry for the typo).

however, Ctrl-\ may send either the Posix "Quit" (SIGQUIT) or the Ansi "Abort" (SIGABRT) - it's terminal-dependent.
abc_coder is offline   Reply With Quote
Old 01-18-2004, 04:15 AM   #6
Registered User
 
Join Date: Dec 2003
Posts: 6
thanks for help buddies....
scorpio_IITR is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Exiting the program. Taka C Programming 6 10-14-2007 09:24 AM
How to tell when internal program is done running PJYelton Windows Programming 5 03-21-2005 10:09 PM
Stop the current running program with another C program? sqlin C++ Programming 0 04-27-2003 02:04 AM
exiting program spike232 C# Programming 4 05-25-2002 08:18 PM
prevent exiting Unregistered A Brief History of Cprogramming.com 4 12-12-2001 02:57 PM


All times are GMT -6. The time now is 05:33 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22