Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Signal Handling Problem

x00sumanx00suman Posts: 7Member
Hi All.
I think perl's Signal Handling has a bug.

I tried this
$SIG{INT} = &Ctrl_C;

sub Ctrl_C
{
print "......
";
$SIG{INT} = &Ctrl_C;
$interrupted = 1;
...
}



but when I press Ctrl+C, it some times works, but perl crashes sometimes.

Windows reports as the preocess perl.exe has generated an error. Closing perl.exe ....

I use Win2K Professionl, SP3
Active Perl 5.6.1 Build 635

Can anyone tell me whether it is a Active Perl issue or Win2K issue.

thanks and Regards,
Sumanth Sharma

Comments

  • JonathanJonathan Posts: 2,914Member
    : I think perl's Signal Handling has a bug.
    :
    : I tried this
    : $SIG{INT} = &Ctrl_C;
    :
    : sub Ctrl_C
    : {
    : print "......
    ";
    : $SIG{INT} = &Ctrl_C;
    Why are you re-assigning the signal handler inside the handling sub?

    : $interrupted = 1;
    : ...
    : }
    :
    : but when I press Ctrl+C, it some times works, but perl crashes
    : sometimes.
    :
    : Windows reports as the preocess perl.exe has generated an error.
    : Closing perl.exe ....
    :
    : I use Win2K Professionl, SP3
    : Active Perl 5.6.1 Build 635
    :
    : Can anyone tell me whether it is a Active Perl issue or Win2K issue.
    :
    Depends how you define "issue". :-) Windows ain't really into signals, which is part of the problem (interestingly, I've been looking into this area for Parrot internals of late, which is the runtime engine for Perl 6). I'm running ActivePerl 5.8, which doesn't exhibit the problem you showed. I know 5.8 also had additional fixes for things that previously could go wrong under Win32, so it may be a good idea for you to upgrade.

    Before that, try removing the line I asked about earlier, 'cus your program works without it so far as I can see and there certainly are things that you probably shouldn't do in signal handlers.

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • x00sumanx00suman Posts: 7Member
    hi Jonathan,

    I will have to re-assign, 'coz if a user again presses CTRL+C, the SIG{INT} would have got reset, and hence will not call my subroutine again. I have testted it. So re-assigning is required.

    But thanks again, as you said, may be perl 5.8.3{latest} has got the fix for this.

    I'll try with 5.8.xx and come back to you.

    Thanks again.

    : Depends how you define "issue". :-) Windows ain't really into signals, which is part of the problem (interestingly, I've been looking into this area for Parrot internals of late, which is the runtime engine for Perl 6). I'm running ActivePerl 5.8, which doesn't exhibit the problem you showed. I know 5.8 also had additional fixes for things that previously could go wrong under Win32, so it may be a good idea for you to upgrade.
    :
    : Before that, try removing the line I asked about earlier, 'cus your program works without it so far as I can see and there certainly are things that you probably shouldn't do in signal handlers.
    :
    : Jonathan
    :
    : ###
    : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    :
    :

  • JonathanJonathan Posts: 2,914Member
    Hi,

    : I will have to re-assign, 'coz if a user again presses CTRL+C, the
    : SIG{INT} would have got reset, and hence will not call my subroutine
    : again. I have testted it. So re-assigning is required.
    :
    I'd disagree. Maybe you have to do that because 5.6.1 is buggy, but it should not need it to be reset; see the below test results.

    On Windows, Perl 5.8:-
    [code]C:Documents and SettingsJonathan>type test.pl
    $SIG{INT} = &Ctrl_C;

    while (1) { };

    sub Ctrl_C
    {
    print "......
    ";
    }
    C:Documents and SettingsJonathan>perl test.pl
    ......
    ......
    ......
    ......
    ......
    ......
    ......
    [/code]

    On Linux, Perl 5.6.1:-
    [code][jonathan@trinity jonathan]$ cat test.pl
    $SIG{INT} = &Ctrl_C;

    while (1) { };

    sub Ctrl_C
    {
    print "......
    ";
    }

    [jonathan@trinity jonathan]$ perl test.pl
    ......
    ......
    ......
    ......
    ......[/code]

    As you can see, I can press Ctrl+C many times without having to reset it.

    : But thanks again, as you said, may be perl 5.8.3{latest} has got the
    : fix for this.
    :
    : I'll try with 5.8.xx and come back to you.
    :
    Here's hoping. They certainly fixed some things in 5.8.xx; fork() for starters.

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • x00sumanx00suman Posts: 7Member
    Hi,

    I will have to trust you. As you said I think perl 5.6.1 on windows has a bug. It gets reset, or may be the perl 5.6.1 PRD is like that. Anyways I cannot afford to switch to 5.6.1 on my office network, for we run regressions using 5.6.1.


    But I have a request.
    Can you tell me WHERE SHOULD I FILE A BUG ON PERL/.

    I have another bug to report on perl's rename() function.

    IF YOU ARE INTERESTED; I CAN GIVE YOU A SCRIPT TO RERPODUCE THE PERL'S RENAME PROBLEM!.




  • JonathanJonathan Posts: 2,914Member
    Hi,

    : I will have to trust you. As you said I think perl 5.6.1 on windows
    : has a bug. It gets reset, or may be the perl 5.6.1 PRD is like that.
    : Anyways I cannot afford to switch to 5.6.1 on my office network, for
    : we run regressions using 5.6.1.
    :
    Note that there is a 5.6.2 which does have some Win32 improvements. It may be worth checking out; see here:-
    http://dev.perl.org/perl5/news/2003/perl-5.6.2.html

    : But I have a request.
    : Can you tell me WHERE SHOULD I FILE A BUG ON PERL/.
    :
    : I have another bug to report on perl's rename() function.
    :
    Check here:-
    http://rt.perl.org/perlbug/

    : IF YOU ARE INTERESTED; I CAN GIVE YOU A SCRIPT TO RERPODUCE THE
    : PERL'S RENAME PROBLEM!.
    :
    Yes, please - I'd be interested to see it.

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • x00sumanx00suman Posts: 7Member
    : : IF YOU ARE INTERESTED; I CAN GIVE YOU A SCRIPT TO RERPODUCE THE
    : : PERL'S RENAME PROBLEM!.
    : :
    : Yes, please - I'd be interested to see it.
    :
    : Jonathan

    ---- I have posted the information as a new message.
    Please check it. [ Bug in Perl rename() function ]

    Again, thanks for the valuable piece of information

    Sumanth Sharma.
Sign In or Register to comment.