Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
app terminating feature test... anyone?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo Chat
View previous topic :: View next topic  
Author Message
Beckman
Tux's lil' helper
Tux's lil' helper


Joined: 10 May 2004
Posts: 94

PostPosted: Wed Dec 15, 2004 1:35 pm    Post subject: app terminating feature test... anyone? Reply with quote

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
View user's profile Send private message
Athas
Guru
Guru


Joined: 04 Sep 2003
Posts: 394
Location: Brøndby, Denmark

PostPosted: Wed Dec 15, 2004 2:55 pm    Post subject: Reply with quote

Um, do you propose that we disassemble your binary to fix the problem? How about some source code? ;)
_________________
Emacs-optimized danish console keymap - My .emacs
Climacs - next generation Emacs.
Back to top
View user's profile Send private message
Beckman
Tux's lil' helper
Tux's lil' helper


Joined: 10 May 2004
Posts: 94

PostPosted: Wed Dec 15, 2004 10:26 pm    Post subject: Reply with quote

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
View user's profile Send private message
Beckman
Tux's lil' helper
Tux's lil' helper


Joined: 10 May 2004
Posts: 94

PostPosted: Fri Dec 17, 2004 10:56 pm    Post subject: Reply with quote

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 :D
_________________
ceterum censeo microsoft esse delendam
Screenshot
xchannel.org - The Supreme IRC Network
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo Chat All times are GMT
Page 1 of 1

 
Jump to:  
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