My app is running in console mode and I need to do some clean up when the app is being killed.
Does anybody know how to catch the app shutdown event?
I have already searched the forum and only microsoft window based version of shutdown function is shown. How about Linux version?
How to capture the shutdown event inconsole [SOLVED]
-
SkyManager
- Enthusiast

- Posts: 339
- Joined: Tue Jan 30, 2007 5:47 am
- Location: Hong Kong
How to capture the shutdown event inconsole [SOLVED]
Last edited by SkyManager on Sun Apr 01, 2007 8:53 pm, edited 1 time in total.
-
SkyManager
- Enthusiast

- Posts: 339
- Joined: Tue Jan 30, 2007 5:47 am
- Location: Hong Kong
here's a short example.... be aware that the SIGKILL can't be catched....
@FRED: may the list of constants can be added to PB?
Compile this little demo and start the exe from a terminal. Open a 2nd Term and do a ps -A to get the process number. Then do a kill -s SIGQUIT <number of your process> and see....
@FRED: may the list of constants can be added to PB?
Code: Select all
; demo for the use of *nix signals from within PB
; can be used in GUI applications too
; 2007 walker
;-------------------------------------------------
#SIGHUP = 1
#SIGINT = 2
#SIGQUIT = 3
#SIGILL = 4
#SIGTRAP = 5
#SIGABRT = 6
#SIGBUS = 7
#SIGFPE = 8
#SIGKILL = 9
#SIGUSR1 = 10
#SIGSEGV = 11
#SIGUSR2 = 12
#SIGPIPE = 13
#SIGALRM = 14
#SIGTERM = 15
#SIGSTKFLT = 16
#SIGCHLD = 17
#SIGCONT = 18
#SIGSTOP = 19
#SIGTSTP = 20
#SIGTTIN = 21
#SIGTTOU = 22
#SIGURG = 23
#SIGXCPU = 24
#SIGXFSZ = 25
#SIGVTALRM= 26
#SIGPROF = 27
#SIGWINCH = 28
#SIGIO = 29
#SIGPWR = 30
#SIGSYS = 31
ProcedureC on_killed_do(signum)
PrintN( "killed")
End
EndProcedure
signal_(#SIGINT,@on_killed_do())
signal_(#SIGQUIT,@on_killed_do())
OpenConsole()
PrintN("kill me from outside...")
Inkey()
CloseConsole()
End
Last edited by walker on Mon Apr 02, 2007 9:28 pm, edited 1 time in total.
-
SkyManager
- Enthusiast

- Posts: 339
- Joined: Tue Jan 30, 2007 5:47 am
- Location: Hong Kong
-
SkyManager
- Enthusiast

- Posts: 339
- Joined: Tue Jan 30, 2007 5:47 am
- Location: Hong Kong


