Re: [perl-win32-gui-users] terminate program at windows logoff

Hi,
I'm not sure if signals is the way to go - you might have a bit more joy =
with hooking the one of the windows shutdown messages
http://msdn.microsoft.com/library/default.asp?url=3D/library/en-us/sysinf=
o/base/system_shutdown_messages.asp
cheers,
jez.
----- Original Message -----=20
From: Calvin Perine=20
To: journey@...=20
Cc: perl-win32-gui-users@...=20
Sent: Wednesday, December 22, 2004 5:17 PM
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@... ~ by mistake)
Thanks Greg...but that didn't work.
I tried $SIG{__DIE__} =3D $SIG{QUIT} =3D $SIG{HUP} =3D $SIG{INT} =3D =
$SIG{KILL} =3D $SIG{QUIT} =3D $SIG{TERM} =3D $SIG{STOP} =3D $SIG{BREAK} =
=3D $SIG{ABRT} =3D \&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=20
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 =3D HUP, INT, PIPE, TERM
error =3D ABRT, BUS, EMT, FPE, ILL, QUIT, SEGV, SYS, TRAP
- according to O'Reilly's PERL Cookbook.
- Calvin Perine
>>> Greg Osborne <journey@...> 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,=20
the SIGHUP signal is sent to any programs that person has opened. =20
Typically this kills the programs, but some programs will catch the =
signal=20
and then perform tasks to stay alive (such as forking into the =
background)=20
or perform some save/cleanup code before exiting. You might try =
trapping=20
that signal.
Another thought is SIGKILL or SIGQUIT, but those may not be as likely =
to=20
give what you want.
Hope it helps.
- Greg
>>> Greg Osborne <journey@...> 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,=20
the SIGHUP signal is sent to any programs that person has opened. =20
Typically this kills the programs, but some programs will catch the =
signal=20
and then perform tasks to stay alive (such as forking into the =
background)=20
or perform some save/cleanup code before exiting. You might try =
trapping=20
that signal.
Another thought is SIGKILL or SIGQUIT, but those may not be as likely =
to=20
give what you want.
Hope it helps.
- Greg

Thread view

(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@... ~ 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@...> 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@...> 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

Hi,
I'm not sure if signals is the way to go - you might have a bit more joy =
with hooking the one of the windows shutdown messages
http://msdn.microsoft.com/library/default.asp?url=3D/library/en-us/sysinf=
o/base/system_shutdown_messages.asp
cheers,
jez.
----- Original Message -----=20
From: Calvin Perine=20
To: journey@...=20
Cc: perl-win32-gui-users@...=20
Sent: Wednesday, December 22, 2004 5:17 PM
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@... ~ by mistake)
Thanks Greg...but that didn't work.
I tried $SIG{__DIE__} =3D $SIG{QUIT} =3D $SIG{HUP} =3D $SIG{INT} =3D =
$SIG{KILL} =3D $SIG{QUIT} =3D $SIG{TERM} =3D $SIG{STOP} =3D $SIG{BREAK} =
=3D $SIG{ABRT} =3D \&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=20
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 =3D HUP, INT, PIPE, TERM
error =3D ABRT, BUS, EMT, FPE, ILL, QUIT, SEGV, SYS, TRAP
- according to O'Reilly's PERL Cookbook.
- Calvin Perine
>>> Greg Osborne <journey@...> 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,=20
the SIGHUP signal is sent to any programs that person has opened. =20
Typically this kills the programs, but some programs will catch the =
signal=20
and then perform tasks to stay alive (such as forking into the =
background)=20
or perform some save/cleanup code before exiting. You might try =
trapping=20
that signal.
Another thought is SIGKILL or SIGQUIT, but those may not be as likely =
to=20
give what you want.
Hope it helps.
- Greg
>>> Greg Osborne <journey@...> 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,=20
the SIGHUP signal is sent to any programs that person has opened. =20
Typically this kills the programs, but some programs will catch the =
signal=20
and then perform tasks to stay alive (such as forking into the =
background)=20
or perform some save/cleanup code before exiting. You might try =
trapping=20
that signal.
Another thought is SIGKILL or SIGQUIT, but those may not be as likely =
to=20
give what you want.
Hope it helps.
- Greg

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@...
[mailto:perl-win32-gui-users-admin@...] On Behalf Of
Calvin Perine
Sent: Wednesday, December 22, 2004 19:17
To: journey@...
Cc: perl-win32-gui-users@...
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@... ~ 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@...> 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@...> 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