How do I propagate an exception thrown by croak in forked child to parent/foreground process?
- by Pedro Silva
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.