How do I propagate an exception thrown by croak in forked child to parent/foreground process?
Posted
by Pedro Silva
on Stack Overflow
See other posts from Stack Overflow
or by Pedro Silva
Published on 2010-06-01T06:39:58Z
Indexed on
2010/06/01
6:43 UTC
Read the original article
Hit count: 212
Throwing an exception via croak
in a forked child process seems to print the error as a background process would. That is, it clobbers the shell prompt.
If I die
instead of croak
, the the error message pops up as a foreground process. I've trying to find out why that is in the Carp
documentation without any luck.
Here's what I mean. The croak
version:
$ perl Wrapper.pm
$ error: ... does not exist at Wrapper.pm line 624
The die
version:
$ perl Wrapper.pm
error: ... does not exist at Wrapper.pm line 515.
I tried trapping the fork
and printing $@
to STDERR and exiting, but that didn't have an effect. Any ideas? I'd like to be able to use croak
in this particular case.
© Stack Overflow or respective owner