Revision history for Perl extension Run.
0.01 Thu Dec 18 14:50:57 1997
- original version; created by h2xs 1.18
0.02: Initial release (chain, or, and, pipe, env, redir).
Redir very fragile in complicated situations (tests 10-13 may fail
depending on what fd were used when started).
0.03: fdopen() is in fact ">&=FOO", thus close of created filehandle
invalidates FOO. Changed to open().
Some tests still do not work right.
0.04: Redirections rewritten. The flakiness had these causes:
- process_close_in_kid() returned false for an empty list, so
redirecting fd N failed silently whenever N was the lowest free fd;
- fd numbers were created by dup()ing up to N and never closed, so
each run changed which fds the next run found free;
- a saved copy of one target could land on a later target, and the
guard against it compared a filehandle with fd numbers;
- restoring with $^F back at 2 set close-on-exec on restored fds and
could move them; with $^F raised, leaked fds lost it instead
(hence "redir.t no. 13 is fragile with this");
- the original F_GETFD result "0 but true" was passed to F_SETFD as a
string, i.e. as a pointer;
- hash order decided the order of redirections at one level;
- ">&=N" filenames were opened before outer redirections were applied;
- "Bad file number" was matched in $! (Linux says "Bad file descriptor").
Now: applied in the kid after fork; with $Run::Wraparound, applied in
the parent around the spawn and restored exactly. Ordered lists,
">&N" and ">&-". New test t/fdtable.t.
0.05: new_pipeline: "a | b | c". Elements other than simple commands
(and, or, chain, pipeline) run in this process, which keeps the
write end open until their last command has ended, as needed for
"{ a || b } | c"; with fork, a second such element runs in a forked
copy.
Fixes:
- new_system/new_spawn with one element ran it as a shell string;
now always "exec { PROG } LIST". The exported spawn() is
unchanged;
- {filename => NAME, mode => OP} opens NAME literally with sh's
< > >| >> <> (2-argument open misread "-", "&1", leading blanks,
and had no "<>");
- $data->{result} was set only on failure and never reset; now the
$? of every system, 0 included, or -1 when nothing started (also
when a new_redir target cannot be opened);
- new_chain failed if any command failed; now the last one decides;
- new_readpipe and new_readpipe_split never reaped their kid (its
pid no longer appears in the caller's $data->{pids});
- an exec failure was reported twice (also as a warning under -w);
messages no longer show a stale $!.
Not tested: the list form "system { PROG } 1, LIST" on OS/2, Win32
and VMS.
New tests t/fixes.t and t/pipeline.t.
0.06: Forkless mode made testable on Unix. $Run::Forkless (true on OS/2,
Win32, VMS; $Run::Wraparound is the old name) routes every process
start through one primitive, spawn_nowait(), as spawnvp(P_NOWAIT):
"system 1, ..." there, fork+exec with nothing in between on Unix.
Nothing else forks when forkless; new_system is spawn_nowait plus
waitpid. New test t/forkless.t checks that every fork comes from
spawn_nowait, and runs each kind of node forkless.
Fix, found that way: fork_kid's exec-error pipe, created inside the
wraparound, could land on a fd that apply() had closed under a Perl
handle; PerlIO then counted two owners, never closed it, and the
parent hung reading the pipe (depended on which fds were free; seen
in t/fdtable.t under prove). Its handles are now closed at the
fd level too (close_fd).
Keyboard Shortcuts
Global
s
Focus search bar
?
Bring up this help dialog
GitHub
gp
Go to pull requests
gi
Go to GitHub issues (only if GitHub is preferred repository)