Is there any way to disable <Ctrl>+C, <Ctrl>+Z, and <Ctrl>+Break in a FreeBASIC program? As in, prevent users from being able to quit the program?
If it matters I am running Linux.
Preventing <Ctrl>+C possible?
Re: Preventing <Ctrl>+C possible?
Perhaps these threads will be of help :
viewtopic.php?t=6669
https://freebasic.net/forum/viewtopic.php?t=10199
Also , not knowing anything in particular neither on subject nor on Linux then I do not know if this MS article could possibly be of any help )?= :
https://support.microsoft.com/en-us/hel ... d-keyboard
viewtopic.php?t=6669
https://freebasic.net/forum/viewtopic.php?t=10199
Also , not knowing anything in particular neither on subject nor on Linux then I do not know if this MS article could possibly be of any help )?= :
https://support.microsoft.com/en-us/hel ... d-keyboard
Re: Preventing <Ctrl>+C possible?
EDIT: bad, broken code... please refer to fxm's example.
Give you an idea anyway. Unfortunately the C header files for signal handling have not been translated, so you'll have to provide the relevant parts yourself. See fxm's example code.
Give you an idea anyway. Unfortunately the C header files for signal handling have not been translated, so you'll have to provide the relevant parts yourself. See fxm's example code.
Last edited by caseih on Oct 14, 2017 14:19, edited 1 time in total.
Re: Preventing <Ctrl>+C possible?
Warnings above fixed:
Code: Select all
#define SIGINT 2
type sigfuncptr as sub(byval signal_number as long)
'posix call
declare function signal cdecl alias "signal" (byval signal as long, byval sigfunc as sigfuncptr) as sigfuncptr
sub sig_handler (byval signo as long)
if signo = SIGINT then
print "received SIGINT!"
end if
end sub
if signal (SIGINT, @sig_handler) = 0 then
print "Can't catch SIGINT."
end if
dim k as string
while 1
k = inkey()
if k <> "" then end
sleep 1
wend
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: Preventing <Ctrl>+C possible?
The user of your App can kill it via taskmanager/processviewer or kill command ...
so what are the sense to disable key's in your App ?
Joshy
so what are the sense to disable key's in your App ?
Joshy
Re: Preventing <Ctrl>+C possible?
It's very common to trap SIGINT in unix programs, especially command-line ones. Trapping Ctrl-C allows you to run a proper shutdown when a user Ctrl-C's the program to quit (again, this is common in command-line programs). Actually it's common to catch SIGHUP, SIGTERM, and SIGINT. A normal kill is SIGTERM.
Thanks for the correct example, dkl. I've been doing too much C++ lately. My code was very wrong!
Thanks for the correct example, dkl. I've been doing too much C++ lately. My code was very wrong!
Re: Preventing <Ctrl>+C possible?
You better rub your eyes and look again.Thanks for the correct example, dkl
Re: Preventing <Ctrl>+C possible?
Ha. yeah. Sorry, fxm!