in reply to (bbfu) Re: QuickPerl: a step up from -e
in thread QuickPerl: a step up from -e

Fork is a little odd in Windows, and doesn't really start a new process. So what will the exec do?!

I think maybe redirect STDERR, and then run Perl feeding it a bootup script which redirects it again before running the real script, but I think that won't work because perl.exe will see and respect the change (again), too.

  • Comment on Re: (bbfu) Re: QuickPerl: a step up from -e

Replies are listed 'Best First'.
(bbfu) Re3: QuickPerl: a step up from -e
by bbfu (Curate) on Jul 05, 2001 at 08:02 UTC

    So what will the exec do?!

    I have no idea. :-p

    Well, system is basically the same thing as fork/exec and my point was basically to do the STDERR redirect between the fork and the exec so that it wouldn't be (temporarily) redirected in the parent. I suppose that it's not really that big of a deal so you might as well just do:

    # # Note: UNTESTED!!! # sub do_run { # write file... local *OLDERR, *NEWERR; open(OLDERR, ">& STDERR") or die "Can't dup STDERR: $!"; pipe(NEWERR, STDERR) or die "Can't pipe: $!"; system "perl quick_run.perl"; open(STDERR, ">& OLDERR") or die "Can't restore STDERR: $!"; my @error_lines = <NEWERR>; return @error_lines; }

    bbfu
    Seasons don't fear The Reaper.
    Nor do the wind, the sun, and the rain.
    We can be like they are.

      I see your point on why it can be useful to separate the two, to do something in between. exec in ActiveState's port sais it will emulate it by starting a new process and then waiting for it to finish, then exiting with the same code itself. So it leaves the old program in memory!