This module provides capture strategies systemsafe, based on
File::Temp, for the traps output layers. These strategies insists on
reopening the output file handles with the same descriptors, and
therefore, unlike Test::Trap::Builder::TempFile and
Test::Trap::Builder::PerlIO, is able to trap output from forked-off
processes, including system().
The import accepts a name (as a string; default systemsafe) and
options (as a hashref; by default empty), and registers a capture
strategy with that name and a variant implementation based on the
Note that you may specify different strategies for each output layer
on the trap.
See also Test::Trap (:stdout and :stderr) and
Using File::Temp, we need privileges to create tempfiles.
We need disk space for the output of every trap (it should clean up
after the trap is sprung).
Disk access may be slow certainly compared to the in-memory files
If the file handle we try to trap using this strategy is on an
in-memory file, it would not be available to other processes in any
case. Rather than change the semantics of the trapped code or
silently fail to trap output from forked-off processes, we just raise
an exception in this case.
If there is another file handle with the same descriptor (f ex after
an open OTHER, >&=, THIS), we cant get that file descriptor.
Rather than silently fail, we again raise an exception.
If the options specify (explicitly or via preserve on handles with)
perlio custom layers, they may (or may not) fail to apply to the
tempfile read and write handles.
Threads? No idea. It might even work correctly.