8

My Racket GUI application needs to do a lot of cleanup work when exiting, i.e. when the user presses the X button. These include killing child processes (which isn't automatic on Windows) etc.

Wrapping the .rkt in a shell script which waits and then does the cleanup is a bit too hacky for me. There are many exit handlers in the Racket documentation (exit-handler etc) but none of them seem to work!

Greg Hendershott
  • 16,100
  • 6
  • 36
  • 53
ithisa
  • 752
  • 1
  • 8
  • 25

1 Answers1

10

You probably want to augment on-close in frame%, for example:

#lang racket/gui

(send
 (new (class frame% (super-new)
        (define/augment (on-close)
          (displayln "Exiting...")))
      [label "Frame"]
      [width 400] [height 200])
 show #t)

which on my machine prints "Exiting..." when I click the closing cross.

Metaxal
  • 1,083
  • 8
  • 10