signal not being caught when re-exec()d

Discussion in 'Perl Misc' started by Jeff 'japhy' Pinyan, Jun 8, 2004.

  1. Here is a very simple demonstration of my problem:

    #!/usr/bin/perl

    BEGIN {
    my @args = ($^X, $0, @ARGV);
    warn "$$: [@args]\n";
    $SIG{USR1} = sub {
    warn "$$: re-exec()ing with [@args]\n";
    exec @args;
    };
    }

    while (1) { }

    I call that code 'exec.pl', and run it thus:

    % perl exec.pl arg &

    and I get

    1234: [/usr/bin/perl exec.pl arg]

    Then I send it a USR1 signal (numerical value is 10):

    % kill -10 1234

    and I get

    1234: re-exec()ing with [/usr/bin/perl exec.pl arg]
    1234: [/usr/bin/perl exec.pl arg]

    Then I try to send it the signal again... and nothing. No messages at
    all. But the program is running, with the same PID... I'm baffled.

    --
    Jeff Pinyan RPI Acacia Brother #734 RPI Acacia Corp Secretary
    "And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
    years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
    Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
     
    Jeff 'japhy' Pinyan, Jun 8, 2004
    #1
    1. Advertising

  2. On 8 Jun 2004, Michal Wojciechowski wrote:

    >When the signal handler is triggered, the signal that caused it to run
    >gets blocked. The new program called with exec inherits the signal
    >mask, and therefore blocks the USR1 signal. To be able to catch it
    >again, you need to reset the signal mask. Use the POSIX sigprocmask
    >function:
    >
    > use POSIX qw:)signal_h);
    >
    > $sigset = POSIX::SigSet->new;
    > sigprocmask(SIG_SETMASK, $sigset);


    Ah ha. Thanks very much.

    --
    Jeff Pinyan RPI Acacia Brother #734 RPI Acacia Corp Secretary
    "And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
    years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
    Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
     
    Jeff 'japhy' Pinyan, Jun 9, 2004
    #2
    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. Eric
    Replies:
    1
    Views:
    554
    =?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBN
    Aug 19, 2005
  2. =?Utf-8?B?Sm9u?=

    ItemDataBound not being caught

    =?Utf-8?B?Sm9u?=, Apr 10, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    495
    jim4u
    Apr 13, 2006
  3. vj
    Replies:
    0
    Views:
    302
  4. Nicolas Moreau
    Replies:
    9
    Views:
    3,369
  5. dibacco73
    Replies:
    1
    Views:
    698
    joris
    Feb 12, 2009
Loading...

Share This Page