View previous topic :: View next topic |
Author |
Message |
Beckman Tux's lil' helper
Joined: 10 May 2004 Posts: 94
|
Posted: Wed Dec 15, 2004 1:35 pm Post subject: app terminating feature test... anyone? |
|
|
im just building the feature into my app, to save the current work when system is going down... (meaning, when it catches the SIGTERM signal)
killall/kill also sends the SIGTERM signal
CTRL+C (when startet in the console sends the SIGINT signal)
on both signals the application reacts just fine...
http://xchannel.org/temp/idie
./idie &
then when rebooting or turning off the machine, it should create a file in the homedir:
~/imdead
but soemhow it doesnt do that. i dont know if its my gentoo's fault, that it doesnt send the sigterm signal to all the apps, or if there is something wrong with my code, cos it does the trick when aborting it or using kill/killall.
language is delphi, built in kylix.
anyone, who would help me out trying that out? _________________ ceterum censeo microsoft esse delendam
Screenshot
xchannel.org - The Supreme IRC Network |
|
Back to top |
|
|
Athas Guru
Joined: 04 Sep 2003 Posts: 394 Location: Brøndby, Denmark
|
|
Back to top |
|
|
Beckman Tux's lil' helper
Joined: 10 May 2004 Posts: 94
|
Posted: Wed Dec 15, 2004 10:26 pm Post subject: |
|
|
i wanted u just to test it, to determine whether my system doesnt send the SIGTERM sig oder theres something wrong with the app..
all i wanted is, that u tell me if it worked for u, that the file is created..
but if u wanna take a look into the code, here it is:
Code: | program temet;
{$APPTYPE CONSOLE}
uses
SysUtils,
libc;
var
bterminate: boolean = false;
//catch kernel signals
procedure SignalProc(SigNum: Integer); cdecl;
begin
case SigNum of
SIGINT: begin
//WriteLn('kernel signal SIGINT caught.');
bTerminate := true;
end;
SIGTERM: begin
//WriteLn('kernel signal SIGTERM caught.');
//--------------------------
//code on SIGTERM signal
libc.system('touch ~/imdead');
//--------------------------
bTerminate := true;
end;
else
WriteLn('not handled kernel signal');
end;
signal(SigNum, SignalProc); //catch the signal again
end;
begin
{ TODO -oUser -cConsole Main : Insert code here }
signal(SIGINT, SignalProc); //catch SIGINT kernel signal
signal(SIGTERM, SignalProc); //catch SIGTERM kernel signal
repeat
sleep(1);
until bTerminate;
end. |
tnx. _________________ ceterum censeo microsoft esse delendam
Screenshot
xchannel.org - The Supreme IRC Network |
|
Back to top |
|
|
Beckman Tux's lil' helper
Joined: 10 May 2004 Posts: 94
|
Posted: Fri Dec 17, 2004 10:56 pm Post subject: |
|
|
k, i found out the prob.
gentoo doesnt seem to send the SIGTERM signal to all the apps. (maybe only to the ones, he started by init script.)
but if i add 'killall [appname]' to /etc/conf.d/local.stop, everything works just fine _________________ ceterum censeo microsoft esse delendam
Screenshot
xchannel.org - The Supreme IRC Network |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|