Professional Web Applications Themes

signal problem - PERL Miscellaneous

Hi, I have a cod as following : .... my $stop = 0; sub my_sigint_catcher { $stop = 1; }; $SIG{'INT'} = 'my_sigint_catcher'; while (1) { .... system("ANOTHER PERL SCRIPT"); ... last if ($stop); } exit 0; Here is my question: 1. The system(" ... ") has its own $SIC{'INT'} handler. Therefore, when I do ctrl-c during this period, the $stop never get set. Is that possible to catch this ctl-c during system("...")'s execution? 2. I thought another easy to fix the problem is to use special combination dedicated for this, such as (F1 key, or CTRL-O). How can I ...

  1. #1

    Default signal problem

    Hi,
    I have a cod as following :

    ....
    my $stop = 0;
    sub my_sigint_catcher {
    $stop = 1;
    };
    $SIG{'INT'} = 'my_sigint_catcher';

    while (1) {
    ....
    system("ANOTHER PERL SCRIPT");
    ...
    last if ($stop);
    }
    exit 0;


    Here is my question:
    1. The system(" ... ") has its own $SIC{'INT'} handler. Therefore, when I do ctrl-c during this period, the $stop never get set.
    Is that possible to catch this ctl-c during system("...")'s execution?
    2. I thought another easy to fix the problem is to use special combination dedicated for this, such as (F1 key, or CTRL-O).
    How can I do this? or where can I find related tutorial?

    Thanks
    Chris

    C&J Guest

  2. #2

    Default Re: signal problem

    [ Please post using plain text -- NOT HTML. TIA ]

    > C&J wrote:
    >
    > I have a cod as following :
    Ok, I'll answer just for the halibut.

    > my $stop = 0;
    > sub my_sigint_catcher {
    > $stop = 1;
    > };
    > $SIG{'INT'} = 'my_sigint_catcher';
    >
    > while (1) {
    > ....
    > system("ANOTHER PERL SCRIPT");
    > ...
    > last if ($stop);
    > }
    > exit 0;
    >
    > Here is my question:
    > 1. The system(" ... ") has its own $SIC{'INT'} handler. Therefore,
    > when I do ctrl-c during this period, the $stop never get set.
    > Is that possible to catch this ctl-c during system("...")'s
    > execution?
    perldoc -q "How do I make a system\(\) exit on control\-C"

    Found in /usr/lib/perl5/5.6.0/pod/perlfaq8.pod
    How do I make a system() exit on control-C?

    You can't. You need to imitate the system() call (see the
    perlipc manpage for sample code) and then have a signal
    handler for the INT signal that passes the signal on to
    the subprocess. Or you can check for it:

    $rc = system($cmd);
    if ($rc & 127) { die "signal death" }

    > 2. I thought another easy to fix the problem is to use special
    > combination dedicated for this, such as (F1 key, or CTRL-O).
    > How can I do this? or where can I find related tutorial?
    perldoc Curses
    perldoc Term::ReadLine



    John
    --
    use Perl;
    program
    fulfillment
    John W. Krahn Guest

Similar Threads

  1. [7.4.1] signal 11 while accesing DB
    By Marcin in forum PostgreSQL / PGSQL
    Replies: 3
    Last Post: January 24th, 07:48 PM
  2. Weal wireless signal
    By Ben Wallach in forum Mac Networking
    Replies: 9
    Last Post: September 13th, 07:21 PM
  3. Replies: 2
    Last Post: September 3rd, 02:59 PM
  4. signal
    By DL in forum UNIX Programming
    Replies: 0
    Last Post: July 11th, 02:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139