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

Discussion in 'Perl Misc' started by Solo, Aug 11, 2004.

  1. Solo

    Solo Guest

    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!!!
     
    Solo, Aug 11, 2004
    #1
    1. Advertising

  2. Solo

    Sisyphus Guest

    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.
     
    Sisyphus, Aug 12, 2004
    #2
    1. Advertising

  3. Solo

    Solo Guest

    Sisyphus <> wrote in message news:<411b063c$0$16324$>...
    > 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.....
     
    Solo, Aug 12, 2004
    #3
  4. Solo

    Sisyphus Guest

    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.
     
    Sisyphus, Aug 13, 2004
    #4
  5. (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.
     
    Scott W Gifford, Aug 13, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Danny

    Implement Ctrl-C, Ctrl-V

    Danny, Aug 14, 2003, in forum: C++
    Replies:
    5
    Views:
    678
    CBFalconer
    Aug 15, 2003
  2. Danny

    Implement Ctrl-C, Ctrl-V

    Danny, Aug 14, 2003, in forum: C Programming
    Replies:
    5
    Views:
    694
    CBFalconer
    Aug 15, 2003
  3. Angus
    Replies:
    5
    Views:
    2,244
    Michael Rauscher
    Nov 18, 2006
  4. Replies:
    2
    Views:
    1,457
    Munna
    Jul 10, 2008
  5. Sol Linderstein
    Replies:
    3
    Views:
    221
    Matt Garrish
    Jun 18, 2004
Loading...

Share This Page