llancet has asked for the wisdom of the Perl Monks concerning the following question:
If I call him, it will say:#!/usr/bin/perl use common::sense; use Glib qw/TRUE FALSE/; $SIG{USR1} = \&on_usr1; my $loop = Glib::MainLoop->new( 'default', FALSE ); $loop->run; sub on_usr1 { my $sig = shift; say "somebody told me $sig"; }
$ ./t_signal.pl & [1] 2637 $ kill -s USR1 2637 somebody told me USR1 $ kill -s USR1 2637 somebody told me USR1 $
and send USR1 using kill, it just crashes:#!/usr/bin/perl use common::sense; use Glib qw/TRUE FALSE/; my $file_pipe = "pipes/$$".'_pipe'; system('mkfifo',$file_pipe)==0 or die $!; my $p_read; open $p_read,'<',$file_pipe or die $!; $SIG{USR1} = \&on_usr1; my $loop = Glib::MainLoop->new( 'default', FALSE ); $loop->run; sub on_usr1 { my $sig = shift; say "somebody told me $sig"; }
Why?$ ./t_signal_1.pl & [1] 2638 $ kill -s USR1 2638 $ [1]+ User defined signal 1 ./t_signal_1.pl $
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: problems on signal handling, Glib mainloop, and named pipe
by ig (Vicar) on Oct 14, 2010 at 07:47 UTC | |
by llancet (Friar) on Oct 14, 2010 at 08:10 UTC | |
by ig (Vicar) on Oct 14, 2010 at 08:17 UTC | |
|
Re: problems on signal handling, Glib mainloop, and named pipe
by zentara (Cardinal) on Oct 14, 2010 at 13:50 UTC |