[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

[RUBY] at_exit kaldes ikke



Hej

Jeg har lidt problemer med en daemon jeg prøver at lave i Ruby.
Noget af det første jeg gør er at kalde følgende funktion:

def enterDaemonMode()
  exit if !fork.nil?
  trap("SIGHUP", "SIG_IGN")
  at_exit {
      $spool.saveState unless $spool.nil?
      $logfile.close unless $logfile.nil?
  }
end

...og det går også godt. Programmet deler sig i to, forælderen afslutter og barnet kører videre i baggrunden. Men hvis jeg dræber barnet med 'kill' så bliver min 'at_exit' blok ikke kørt.
Jeg prøvede også med:


def enterDaemonMode()
  exit if !fork.nil?
  trap("SIGHUP", "SIG_IGN")
  trap("EXIT") {
      $spool.saveState unless $spool.nil?
      $logfile.close unless $logfile.nil?
  }
end

...men med samme resultat. Jeg vil meget gerne kunne starte min daemon ved opstart af min maskine og så gemme tilstanden når maskinen lukkes ned eller jeg selv dræber processen. Hvad gør jeg forkert ?
Jeg ved godt at jeg kan lytte efter andre signaler og så sende dette signal for at afslutte pænt, men jeg vil meget gerne have at programmet afslutter pænt ligegyldigt hvad.


VH
Robert


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-12-01, 02:01 CET [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *