NAME
Skilletor::Process - Run a program without a shell – cwd, environment, timeout, captured output
VERSION
version 0.008000
SYNOPSIS
use Skilletor::Process qw( run_command );
my $r = run_command(
cmd => [ 'git', 'rev-parse', 'HEAD' ],
cwd => $dir,
env => \%env, # the whole environment of the child
timeout_ms => 60_000,
stdin => $bytes, # optional; else stdin is /dev/null
);
print $r->{stdout} if defined $r->{code} && $r->{code} == 0;
DESCRIPTION
What the reference gets from Node's execFile: a program and its arguments as a list (never a shell), a working directory, a complete environment, a timeout after which the child gets SIGTERM, and stdout and stderr captured as bytes. Nothing of the parent's state changes. Stdin is /dev/null, or a pipe that gets stdin's bytes and then end of file, as execFileSync's input gives it.
On Windows ($^O MSWin32), which has no fork, no select on pipes and no signals, the same calls take a path of their own, with the same results: stdin, stdout and stderr are anonymous temp files, put on the standard handles for the moment of a P_NOWAIT spawn (system 1) of the program as Node would find it on PATH (.com, .exe; never in the working directory first, never a .bat or .cmd), with its arguments quoted for the C runtime's command-line parser; the process is waited for until the timeout, then terminated (TerminateProcess) and reported as Node reports it there, signal 15. A child that ends leaves its output read even if a program it started still holds the handles.
run_command
run_command( cmd => [...], cwd => $dir, env => \%env, timeout_ms => $ms, stdin => $bytes );
Returns { code, signal, stdout, stderr, timed_out, spawn_error? }. code is undef when a signal ended the child. spawn_error ({ stage => 'chdir' | 'exec', errno, message }) says the program never ran: no such directory, no such program.
win32 => { spawn => $code } takes the Windows path on any system, with $code in place of the spawn – $code->( $program, @quoted_args ) returns the pid, else undef and errno – for a test. While the Windows path waits it calls $Skilletor::Process::ON_WAIT, when set, every few ms.
spawn_detached
spawn_detached( cmd => [ $program, @args ], env => \%env );
Starts the program and returns without waiting for it: in a session of its own, stdin, stdout and stderr on /dev/null, the given environment (default: this process's). The background sync of the hooks runs this way. True when the program was started; whether its exec succeeded is not known.
On Windows it is Win32::Process::Create, inheriting no handle (a hook's stdout does not stay open in it), in a process group of its own and with a console of its own that has no window, so neither it nor what it runs flashes one. False there when there is no such program. win32 => { detach => $code } takes this path on any system, $code->( $program, $command_line ) in place of the start, for a test.
SUPPORT
Issues
Please report bugs and feature requests at https://github.com/Getty/skilletor/issues.
CONTRIBUTING
Contributions are welcome! Please fork the repository and submit a pull request.
AUTHOR
Torsten Raudssus <torsten@raudssus.de>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)