Windows Vista Signals

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2008
Posts: 1
Reputation: ceebs is an unknown quantity at this point 
Solved Threads: 0
ceebs ceebs is offline Offline
Newbie Poster

Windows Vista Signals

 
0
  #1
Sep 14th, 2008
Thanks in advance for the help.

I’m fairly new to Python so please forgive me if I don’t quite use the correct terminology.

I have a very simple serial port interface (non-gui) application that I run on windows. Upon closing the window, I want the program to run some cleanup code (ie. Close output files and ports). Originally, on Windows XP (32-bit), using the SIGBREAK signal, it runs my cleanup code as expected when the ‘X’ in the top right corner of the window is pressed. When I run the same program on Windows Vista, it does not run the cleanup code when the window is closed. CTRL+C on both operating systems run the cleanup code as expected. Here is a sample:

  1. def cleanup(signum, frame):
  2. # cleanup code here
  3. print "programmed cleaned up"
  4.  
  5. signal.signal(signal.SIGBREAK, cleanup)
  6. signal.signal(signal.SIGABRT, cleanup)
  7. signal.signal(signal.SIGINT, cleanup)
  8. signal.signal(signal.SIGTERM, cleanup)
  9. signal.signal(signal.SIGFPE, cleanup)
  10. signal.signal(signal.SIGILL, cleanup)
  11. signal.signal(signal.SIGSEGV, cleanup)

Does anyone know any way that I can run cleanup code on a windows vista machine when the window is closed via the ‘X’ in the top right corner of the screen?

By the way, I've also tried the atexit module and the try: except: finally: any they didn't work either. Maybe I'm not using them correctly

Thanks again.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 681 | Replies: 0
Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC