Posted to tcl by Bradipo at Thu Sep 27 18:47:03 GMT 2018view raw

  1. # coming from proc service_control_handler:
  2. all_stopped {
  3. # Mark we are all done so we can exit at global level
  4. set ::done 1
  5. }
  6.  
  7. ...
  8. # how the service begins:
  9. if {[catch {
  10. twapi::run_as_service [list [list $service_name ::service_control_handler]]
  11. } msg]} {
  12. twapi::eventlog_log "Service error: $msg"
  13. }
  14. # We sit in the event loop until service control stop us through
  15. # the event handler
  16. vwait ::done
  17. after 1000