traping signals

Discussion in 'Perl Misc' started by bfay@deepcosmos.ca, Apr 26, 2005.

  1. Guest

    In a script, I trap the interrupt and quit signals. I would like all
    the other signals to be ignored. Is there a simple way to do it?

    Thanks,
    Bernard
    , Apr 26, 2005
    #1
    1. Advertising

  2. wrote:
    > In a script, I trap the interrupt and quit signals. I would like all
    > the other signals to be ignored. Is there a simple way to do it?
    >
    > Thanks,
    > Bernard
    >

    perldoc sigtrap
    perldoc perlipc

    Mark
    Mark Clements, Apr 26, 2005
    #2
    1. Advertising

  3. In article <>,
    <> wrote:
    >In a script, I trap the interrupt and quit signals. I would like all
    >the other signals to be ignored. Is there a simple way to do it?
    >


    Not really. If Unix-based and kill(1) supports -l , you
    could grab the list and set the other signals to ignore:

    { local $SIG{INT} = sub my_int_catcher {...};
    local $SIG{QUIT} = sub my_quit_catcher {...};
    # test kill(1) for -l option ...
    # grab signal list if -l available...
    local $SIG{$_} = 'IGNORE' for @signal_list;
    }

    of course SIGKILL is uncatchable. Also, in some cases
    you might be better off blocking signals rather than
    ignoring them ('Perl Cookbook' has an example of how).

    hth,
    --
    Charles DeRykus
    Charles DeRykus, May 5, 2005
    #3
  4. On 2005-05-05, Charles DeRykus scribbled these
    curious markings:
    > Not really. If Unix-based and kill(1) supports -l , you
    > could grab the list and set the other signals to ignore:


    [non-portable code snipped]

    Instead of giving platform-specific code that returns tainted data, why
    not just use the example given in perlipc?

    I quote:

    The names of the signals are the ones listed out by "kill -l" on
    your system, or you can retrieve them from the Config module. Set up an
    @signame list indexed by number to get the name and a %signo table
    indexed by name to get the number:

    use Config;
    defined $Config{sig_name} || die "No sigs?";
    foreach $name (split(' ', $Config{sig_name})) {
    $signo{$name} = $i;
    $signame[$i] = $name;
    $i++;
    }

    End quote.

    Best Regards,
    Christopher Nehren
    --
    I abhor a system designed for the "user", if that word is a coded
    pejorative meaning "stupid and unsophisticated". -- Ken Thompson
    If you ask the wrong questions, you get answers like "42" and "God".
    Unix is user friendly. However, it isn't idiot friendly.
    Christopher Nehren, May 5, 2005
    #4
  5. In article <>,
    Christopher Nehren <> wrote:
    >On 2005-05-05, Charles DeRykus scribbled these
    >curious markings:
    >> Not really. If Unix-based and kill(1) supports -l , you
    >> could grab the list and set the other signals to ignore:

    >
    >[non-portable code snipped]
    >
    >Instead of giving platform-specific code that returns tainted data, why
    >not just use the example given in perlipc?
    >
    >I quote:
    >
    > The names of the signals are the ones listed out by "kill -l" on
    >your system, or you can retrieve them from the Config module. Set up an
    >@signame list indexed by number to get the name and a %signo table
    >indexed by name to get the number:
    >
    >use Config;
    >defined $Config{sig_name} || die "No sigs?";
    >foreach $name (split(' ', $Config{sig_name})) {
    > $signo{$name} = $i;
    > $signame[$i] = $name;
    > $i++;
    >}
    >


    Um, I stated if "Unix-based" and the snippage included:

    # test kill(1) for -l option ...
    # grab signal list if -l available...

    Moreover, there was actually no 'non-portable' code since
    I didn't explain how to 'test and grab'. I'd agree though
    Config would be the preferable method for generating that
    signal list.

    --
    Charles DeRykus
    Charles DeRykus, May 5, 2005
    #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. Thomas

    unused bits in signals

    Thomas, Jul 6, 2003, in forum: VHDL
    Replies:
    2
    Views:
    1,070
    Mario Trams
    Jul 6, 2003
  2. Ingmar Seifert

    Delay of control signals

    Ingmar Seifert, Aug 18, 2003, in forum: VHDL
    Replies:
    0
    Views:
    1,200
    Ingmar Seifert
    Aug 18, 2003
  3. =?Utf-8?B?Unlhbg==?=

    traping curly apostrophes

    =?Utf-8?B?Unlhbg==?=, Jun 14, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    445
    Steven Cheng[MSFT]
    Jun 16, 2006
  4. sunil

    problem traping event in child control

    sunil, Apr 10, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    124
    Phillip Williams
    Apr 10, 2006
  5. Mário Lopes

    Traping signals on child processes

    Mário Lopes, Jun 2, 2008, in forum: Ruby
    Replies:
    12
    Views:
    286
    ara.t.howard
    Jun 3, 2008
Loading...

Share This Page