Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Signal handling.

 [1/12] from: bga:bug-br at: 12-Nov-2003 17:59


Hello. Is there any way to handle signals sent to a rebol script? I have this script that *MUST* clean-up when receiving a SIGTERM. Thanks. -Bruno

 [2/12] from: greggirwin:mindspring at: 12-Nov-2003 13:03


Hi Bruno, BGA> Is there any way to handle signals sent to a rebol script? I have this BGA> script that *MUST* clean-up when receiving a SIGTERM. You can use the system port in View/Pro or SDK. -- Gregg

 [3/12] from: SunandaDH:aol at: 12-Nov-2003 15:18


Bruno:
> Is there any way to handle signals sent to a rebol script? I have this > script that *MUST* clean-up when receiving a SIGTERM.
Just a guess. Can you trap a SIGTERM with an event handler? This example traps a close event. Not want you want, but maybe SIGTERMS come your way too. unview/all view/new layout [button "click me" [print "you clicked me"]] insert-event-func [ if event/type = 'close [ print "we are going to stop" halt ] print event/type Return event ] do-events

 [4/12] from: bga:bug-br at: 13-Nov-2003 0:58


On Wed, 12 Nov 2003 15:18:12 EST, [SunandaDH--aol--com] said:
> > Is there any way to handle signals sent to a rebol script? I have > > this
<<quoted lines omitted: 14>>
> ] > do-events
Thanks! The problem is that I am just using Rebol/Core. -Bruno -- Fortune Cookie Says: Not only is this incomprehensible, but the ink is ugly and the paper is from the wrong kind of tree. -- Professor W.

 [5/12] from: bga:bug-br at: 13-Nov-2003 0:59


On Wed, 12 Nov 2003 13:03:13 -0700, Gregg Irwin < [greggirwin--mindspring--com]> said:
> BGA> Is there any way to handle signals sent to a rebol script? I > have this > BGA> script that *MUST* clean-up when receiving a SIGTERM. > > You can use the system port in View/Pro or SDK.
I have View/Pro, but the machine where I am running it has no X-Server at all. Would it work with Rebol/Core by any chance? -Bruno -- Fortune Cookie Says: Life may have no meaning -- or even worse, it may have a meaning of which I disapprove.

 [6/12] from: antonr:iinet:au at: 13-Nov-2003 14:11


At bottom is the post of Carl Sassenrate from October last year. Anton.
> Hello. > > Is there any way to handle signals sent to a rebol script? I have this > script that *MUST* clean-up when receiving a SIGTERM. > > Thanks. > > -Bruno
Here is a short script that uses the REBOL system-port to intercept shutdown types of interrupts from various operating systems. Why? For example, you would want to do this if you had a REBOL server process on Linux that has internal state. You may want the chance to write out information to files before quitting. This is the code you need to make it happen. The code below will detect both CTRL-C and REBOL ESCAPE key. enable-system-trap: does [ ; Trap OS interrupts if not system/ports/system [ if none? attempt [system/ports/system: open [scheme: 'system]][ print "NOTE: Missing System Port" exit ] ] if find get-modes system/ports/system 'system-modes 'signal [ set-modes system/ports/system [ signal: intersect get-modes system/ports/system 'signal-names [ sigquit sigterm sigint sighup ] ] ] system/console/break: 'signal append system/ports/wait-list system/ports/system ] check-system-trap: func [port /local msg] [ ; Process OS interrupts if not port? port [return none] if any [port/scheme <> 'system port <> system/ports/system][return port] if not system/ports/system [return none] while [msg: pick system/ports/system 1] [ if find [signal escape] msg/1 [ print ["System Trap:" msg] ; (save files here) quit ] ] none ] print "Starting..." enable-system-trap forever [ wake-port: wait 20 ; timeout period check-system-trap wake-port ]

 [7/12] from: greggirwin:mindspring at: 12-Nov-2003 20:40


Hi Bruno, BGA> I have View/Pro, but the machine where I am running it has no X-Server BGA> at all. Would it work with Rebol/Core by any chance? Yes. Core 2.5.6 includes the system port. I forgot about that. -- Gregg

 [8/12] from: antonr:iinet:au at: 13-Nov-2003 18:50


I am pretty sure you can't do it this way. Anton.

 [9/12] from: antonr::iinet::net::au at: 13-Nov-2003 18:50


That should be Carl Sassenrath. And, the code below works on Core 2.5.6.3.1 and latest View betas > 1.2.1.3.1 (On Windows, ctrl-c is not detected.) Anton.

 [10/12] from: g:santilli:tiscalinet:it at: 13-Nov-2003 10:02


Hi Bruno, On Thursday, November 13, 2003, 2:59:30 AM, you wrote: BGA> I have View/Pro, but the machine where I am running it has no X-Server BGA> at all. Would it work with Rebol/Core by any chance? REBOL/Core 2.5.6.3.1 Copyright 1997-2003 REBOL Technologies REBOL is a Trademark of REBOL Technologies All rights reserved. [...] Component: "System Port" 1.1.2.5 (30-Nov-2002/17:24:03) [...] I think it does. :) Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/

 [11/12] from: g:santilli:tiscalinet:it at: 13-Nov-2003 9:58


Hi Bruno, On Wednesday, November 12, 2003, 8:59:44 PM, you wrote: BGA> Is there any way to handle signals sent to a rebol script? I have this BGA> script that *MUST* clean-up when receiving a SIGTERM. Carl once posted an example about handling signals using the system port. Let me have a look... Here it is: http://www.escribe.com/internet/rebol/m26488.html Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/

 [12/12] from: nitsch-lists:netcologne at: 13-Nov-2003 12:35


Am Donnerstag, 13. November 2003 02:58 schrieb Bruno G. Albuquerque:
> > > Is there any way to handle signals sent to a rebol script? I have > > > this > > > script that *MUST* clean-up when receiving a SIGTERM.
I remember Carl posted an example with system-port. trapped ctrl-c IIRC, and it should work similar with other signals. was on the ML IIRC, but can't find it. -Volker

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted