Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to catch CTRL-C in Windows NT cmd.exe???

Reply
Thread Tools

How to catch CTRL-C in Windows NT cmd.exe???

 
 
Solo
Guest
Posts: n/a
 
      08-11-2004
I wrote the following code just to test the catch of Ctrl-C:
---------------

{

$SIG{'INT'} = \&cmd1;


print "Entering the loop \n\n";
while (1)
{
}

}

sub cmd1
{
my ($sig) = @_;
print "The Interrupt was caught: <$sig>\n";
exit (0);
}

--------------------
It works perfectly on UNIX, But in the windows NT cmd.exe or 4NT prompt, it
just kills the process and does not display the print message...

HELP!!!
 
Reply With Quote
 
 
 
 
Sisyphus
Guest
Posts: n/a
 
      08-12-2004
Solo wrote:
> I wrote the following code just to test the catch of Ctrl-C:
> ---------------
>
> {
>
> $SIG{'INT'} = \&cmd1;
>
>
> print "Entering the loop \n\n";
> while (1)
> {
> }
>
> }
>
> sub cmd1
> {
> my ($sig) = @_;
> print "The Interrupt was caught: <$sig>\n";
> exit (0);
> }
>
> --------------------
> It works perfectly on UNIX, But in the windows NT cmd.exe or 4NT prompt, it
> just kills the process and does not display the print message...
>
> HELP!!!


It works fine for me in a cmd.exe shell on Windows 2000, and displays
the print message. Is that a copy'n'paste of the actual program that's
failing on NT ?

Cheers,
Rob

--
To reply by email u have to take out the u in kalinaubears.

 
Reply With Quote
 
 
 
 
Solo
Guest
Posts: n/a
 
      08-12-2004
Sisyphus <(E-Mail Removed)> wrote in message news:<411b063c$0$16324$(E-Mail Removed)>...
> Solo wrote:
> > I wrote the following code just to test the catch of Ctrl-C:
> > ---------------
> >
> > {
> >
> > $SIG{'INT'} = \&cmd1;
> >
> >
> > print "Entering the loop \n\n";
> > while (1)
> > {
> > }

>
> > }
> >
> > sub cmd1
> > {
> > my ($sig) = @_;
> > print "The Interrupt was caught: <$sig>\n";
> > exit (0);
> > }
> >
> > --------------------
> > It works perfectly on UNIX, But in the windows NT cmd.exe or 4NT prompt, it
> > just kills the process and does not display the print message...
> >
> > HELP!!!

>
> It works fine for me in a cmd.exe shell on Windows 2000, and displays
> the print message. Is that a copy'n'paste of the actual program that's
> failing on NT ?
>
> Cheers,
> Rob



Yes, it's an actual cut'n'paste.....
 
Reply With Quote
 
Sisyphus
Guest
Posts: n/a
 
      08-13-2004
Solo wrote:

>>
>>It works fine for me in a cmd.exe shell on Windows 2000, and displays
>>the print message. Is that a copy'n'paste of the actual program that's
>>failing on NT ?
>>
>>Cheers,
>>Rob

>
>
>
> Yes, it's an actual cut'n'paste.....


So much for that idea then ......
What does 'perl -V' report ?

Faik, the difference might be that you are running NT and I'm running
2000 - but, I've not come across such a difference between the 2
operating systems in the past.

Cheers,
Rob


--
To reply by email u have to take out the u in kalinaubears.

 
Reply With Quote
 
Scott W Gifford
Guest
Posts: n/a
 
      08-13-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) (Solo) writes:

> I wrote the following code just to test the catch of Ctrl-C:
> ---------------
>
> {
>
> $SIG{'INT'} = \&cmd1;


Try using $SIG{BREAK} instead. I recall that working for me, though I
don't recall where I read it.

----ScottG.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
catch doesn't catch a thrown exception Marteno Rodia Java 5 08-05-2009 03:30 AM
catch(...) doesn't catch everything Adam C++ 9 02-02-2006 05:02 PM
windows authentication: how to catch the case a user entered a wrongpassword Dan ASP .Net 2 12-07-2004 01:20 PM
why catch (...) can not catch such exception John Black C++ 8 08-20-2004 02:34 PM



Advertisments