Hi all,

  I have solved the problem using a module called Exception.pm, it
  provides a very good interface for exception handling and I was able
  to bypass the die bug not being trapped by the eval block.

Best wishes,

Luiz Fernando B. Ribeiro

use Exception qw(:all);

...

$fifo = "$pasta/$fifo";

# 5 segundo de timeout no fifo...
my $block = new Exception;
my $fifo_ok =
   try {
       $SIG{ALRM} = sub { $block->raise };
       alarm 5;
       open(FIFO, ">$fifo");
       alarm 0;
       return 1;
   } when $block, except {
       debug("FIFO $fifo est� surdo...");
       return 0;
   };

if ($fifo_ok) {
   print FIFO $msg;
   close FIFO;
}

Resposta a sua mensagem de ter�a-feira, 19 de fevereiro de 2002:

LFBR> Hello,

LFBR>   I'm having trouble with the common technique (alarm eval{}) to avoid
LFBR>   blocking operations. The die message is always going to the browser
LFBR>   even when trapped by the eval block.

LFBR> eval {
LFBR>      local $SIG{ALRM} = sub {die};
LFBR>      alarm 3;
LFBR>      open(FIFO,">$fifo");
LFBR>      alarm 0;
LFBR> };
LFBR> if ($@) {
LFBR>    debug("Cliente ausente...");
LFBR>    close(FIFO);
LFBR> } else {
LFBR>   print FIFO ">TERM";
LFBR>   close(FIFO);
LFBR> }

LFBR>   The alarm is being called and the debug message is print but in the
LFBR>   browser I get the embperl message about the die:

LFBR>   [1485]ERR: 24: Line 104: Error in Perl code: Died at ...

LFBR> Any clues or wokarounds?

LFBR> Thanks in advance.

LFBR> Luiz Fernando B. Ribeiro


LFBR> ---------------------------------------------------------------------
LFBR> To unsubscribe, e-mail: [EMAIL PROTECTED]
LFBR> For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to