Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > traping signals

Reply
Thread Tools

traping signals

 
 
bfay@deepcosmos.ca
Guest
Posts: n/a
 
      04-26-2005
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

 
Reply With Quote
 
 
 
 
Mark Clements
Guest
Posts: n/a
 
      04-26-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) 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
 
Reply With Quote
 
 
 
 
Charles DeRykus
Guest
Posts: n/a
 
      05-05-2005
In article <(E-Mail Removed) .com>,
<(E-Mail Removed)> 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
 
Reply With Quote
 
Christopher Nehren
Guest
Posts: n/a
 
      05-05-2005
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.
 
Reply With Quote
 
Charles DeRykus
Guest
Posts: n/a
 
      05-05-2005
In article <(E-Mail Removed) >,
Christopher Nehren <(E-Mail Removed)> 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
 
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
Traping signals on child processes Mário Lopes Ruby 12 06-03-2008 04:12 PM
traping curly apostrophes =?Utf-8?B?Unlhbg==?= ASP .Net 4 06-16-2006 03:10 AM
problem traping event in child control sunil ASP .Net Web Controls 1 04-10-2006 02:21 PM
Delay of control signals Ingmar Seifert VHDL 0 08-18-2003 03:21 PM
unused bits in signals Thomas VHDL 2 07-06-2003 10:22 PM



Advertisments