sean finney on 1 Nov 2003 02:32:03 -0500


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

(solved) Re: [PLUG] fun with perl: eval{} and exceptions


hi,

On Fri, Oct 31, 2003 at 08:44:25PM -0700, Kyle R. Burton wrote:
> Well, I just hacked togeather some test code and it looks like open3
> first creates pipes appropriately, then forks, and then attempts to
> exec the command.

and there's the problem!  so when the call to a forked exec fails, the
child continues through the rest of the perl code just like the parent,
with its own copies of variables.  this explains the schizophrenic 2
emails with different variable values, and also why the output from
the script was showing up as output from the exec'd process in one of
the emails.  that actually makes sense when you remember that all of
these functions are just based around the underlying c functions... 
except as usual perl does it their own special way, like not returning
an error value when exec fails.

so for anyone who's interested, what i'm doing now is if open3 throws
an exception, the child sends a SIGCHLD signal to the parent, everyone
sets $exec_failure, and we put an additional constraint in the block of
code deciding what happened with the execution.


allright, thanks for the insight!
	sean

Attachment: signature.asc
Description: Digital signature