Calvin,
 
From the ActiveState FAQ:

"Signals are unsupported by the Win32 API. The C Runtime provides crude support for signals, but there are serious caveats, such as inability to die() or exit() from a signal handler. Perl itself does not guarantee that signal handlers will not interrupt critical operations such as memory allocation, which means signal invocation may throw perl internals into disarray. For these reasons, signals are unsupported at this time."

So, I think that Jez is on the right track with his Windows shutdown message idea. Having said that,  inserting this in your program does prevent the Windows end program dialog from appearing at logoff:
 
$SIG{QUIT} = 'DEFAULT';
 
but I, too, was unable to install a different handler, probably for the reasons stated in the FAQ.
 
Glenn



From: perl-win32-gui-users-admin@lists.sourceforge.net [mailto:perl-win32-gui-users-admin@lists.sourceforge.net] On Behalf Of Calvin Perine
Sent: Wednesday, December 22, 2004 19:17
To: journey@eagle.ontheside.net
Cc: perl-win32-gui-users@lists.sourceforge.net
Subject: [perl-win32-gui-users] terminate program at windows logoff

(Just as a note: I changed the subject to reflect the content of the post!
It was originally [perl-win32-gui-users] perl-win32-gui-users@lists.sourceforge.net  ~ by mistake)
 
Thanks Greg...but that didn't work.
I tried  $SIG{__DIE__} = $SIG{QUIT} = $SIG{HUP} = $SIG{INT} = $SIG{KILL} = $SIG{QUIT} = $SIG{TERM} = $SIG{STOP} = $SIG{BREAK} = $SIG{ABRT} = \&Main_Terminate;
where Main_Terminate is the method that I am using as the handler.
But no success for logoff.
I am getting a list of signals using the following at a cmd prompt in Windows XP (SP2):
 
C:\>perl -e "print join(' ', keys %SIG)"
ABRT BREAK HUP NUM19 FPE CLD NUM12 NUM16 NUM18 NUM17 STOP NUM24 NUM10 INT SEGV
QUIT KILL PIPE NUM05 CONT NUM06 NUM07 ILL TERM ALRM CHLD
 
I also tried the following instead of using the SIG hash:
 use sigtrap qw(handler Main_Terminate normal-signals error-signals);
which from what I understand should define the handler as Main_Terminate for all signals in the normal and error lists
    normal = HUP, INT, PIPE, TERM
    error = ABRT, BUS, EMT, FPE, ILL, QUIT, SEGV, SYS, TRAP
    - according to O'Reilly's PERL Cookbook.
 
- Calvin Perine

>>> Greg Osborne <journey@eagle.ontheside.net> 12/22/2004 11:17:29 AM >>>
I'm taking a stab in the dark here, but...

When a unix or linux system sees a user leave or lose connection,
the SIGHUP signal is sent to any programs that person has opened. 
Typically this kills the programs, but some programs will catch the signal
and then perform tasks to stay alive (such as forking into the background)
or perform some save/cleanup code before exiting.  You might try trapping
that signal.

Another thought is SIGKILL or SIGQUIT, but those may not be as likely to
give what you want.

Hope it helps.

- Greg


>>> Greg Osborne <journey@eagle.ontheside.net> 12/22/2004 11:17:29 AM >>>
I'm taking a stab in the dark here, but...

When a unix or linux system sees a user leave or lose connection,
the SIGHUP signal is sent to any programs that person has opened. 
Typically this kills the programs, but some programs will catch the signal
and then perform tasks to stay alive (such as forking into the background)
or perform some save/cleanup code before exiting.  You might try trapping
that signal.

Another thought is SIGKILL or SIGQUIT, but those may not be as likely to
give what you want.

Hope it helps.

- Greg