Worth a looka fix or feature you may wantThe raw payload has no build numbers and no superseded_by fields. Upgrade guidance therefore uses only the visible commit sequence and the exact diffs, without inventing a build range or a later status claim.
External processes gain cross-platform stream control
A new TExternalProcess class brings redirected stdin, stdout and stderr to Windows and POSIX, with callbacks, buffered reads and process-tree termination. POSIX RunRedirect now uses the same machinery, and a follow-up avoids scanning huge descriptor limits before every child launch. Delphi and FPC backends are both covered, but the intermediate Windows and Delphi POSIX revisions should not be taken without their later fixes.
TL;DR
- TExternalProcess is a new public API for interactive child processes with redirected input and separate or merged output streams.
- Windows uses an inherited-handle allow-list and a job object; POSIX uses close-on-exec pipes, process groups and explicit descriptor cleanup.
- POSIX RunRedirect now uses TExternalProcess, while Windows RunRedirect continues to use RunCommandWin.
- The final Delphi Linux follow-up fixes signed descriptor types and was tested with Delphi 13 on Linux64.
Upgrade advice
Take the complete PR #734 merge, not an intermediate revision. The first Windows implementation is followed by thread-safe startup API resolution, and the first Delphi POSIX enablement is followed by a required signed-descriptor compile fix. The raw payload contains neither build metadata nor superseded_by records, so no build range is claimed.
7 of 7 entries · 8 commits upstream
1
Medium
Windows process attributes are resolved before concurrent use
mormot.core.os.windows moves resolution of InitializeProcThreadAttributeList, UpdateProcThreadAttribute and DeleteProcThreadAttributeList into InitializeSpecificUnit. HasProcThreadAttribute now only checks the three function pointers. This removes the mutable ProcThreadAttributeChecked flag and the unlocked GetProcAddress sequence from the first TExternalProcess launch.
Fixes
mormot.core.os.windows
d1de8cc6+5-13
core: TExternalProcess resolves the Windows attribute list API at startup - see #648
Impact
Delphi and FPC Windows servers can create the first TExternalProcess instances from multiple threads without racing during Vista+ API discovery. Systems lacking the APIs still use the existing serialized inheritance fallback. No application API changes.
Upgrade recommended
If you adopted the Windows implementation from 4b165bd9, move at least to d1de8cc6 or to the complete PR #734 merge before enabling concurrent process launches.
2
Medium
A stateful child-process API can stream input and output
mormot.core.os adds TExternalProcess and TExternalProcessState. Start accepts either a command line or an argument array; Write and CloseStdin feed stdin; callbacks or ReadAvailable and ReadErrorAvailable consume output. New TRunOptions members select null or piped stdin and merged or separate stderr. The POSIX backend uses close-on-exec pipes, execve, a process group and a background reader, and POSIX RunRedirect is rebuilt on the same class. At this revision the Windows methods are still stubs.
New features
mormot.core.os+2
cd48e5ef+1478-129
core: new TExternalProcess class with redirected stdin/stdout/stderr - see #648
Impact
Delphi and FPC applications gain a non-shell API for long-running or interactive children on POSIX, including controlled stdin and incremental output. Existing POSIX RunRedirect calls keep their signature but now run through new fork, pipe and reap code, so process launch, environment handling and termination behavior are on a new path. Windows applications cannot use TExternalProcess at this exact revision and should take the later implementation.
Worth a look
Review POSIX services that depend on RunRedirect timeouts, callbacks or custom environments, and adopt the complete merged series before using TExternalProcess on Windows.
Public API
TExternalProcessadded — Starts a child, redirects streams, reads output and terminates the process tree.TExternalProcessStateadded — Exposes not-started, running, exited and failed states.TRunOptions.roStdinNull/roStdinPipe/roStderrMerge/roStderrPipeadded — Selects stdin and stderr redirection for TExternalProcess.RUN_PROCESSadded — Defaults to null stdin and stderr merged into stdout.RunRedirectbehaviour-changed — The POSIX implementation now runs through TExternalProcess instead of the previous popen path.
3
Medium
Windows children inherit only their assigned standard handles
mormot.core.os.windows implements TExternalProcess with CreateProcessW. On Vista and later, PROC_THREAD_ATTRIBUTE_HANDLE_LIST limits inheritance to the selected stdin, stdout and stderr handles; older systems use a serialized fallback. Each child starts suspended in its own process group and job, then a background thread drains stdout and stderr. Argument arrays are quoted for CommandLineToArgvW, and termination escalates from CTRL_BREAK and WM_QUIT to the whole job.
New features
mormot.core.os+1
4b165bd9+722-22
core: TExternalProcess Windows implementation - see #648
Impact
Delphi and FPC Windows backends can now use the same TExternalProcess API as POSIX without leaking unrelated inheritable handles into children. Process-tree termination is stronger than a single TerminateProcess call, and argument-array launches avoid shell parsing. Windows RunRedirect itself remains on RunCommandWin. Do not stop on this revision because the later d1de8cc6 fix removes an unlocked first-use API lookup.
Worth a look
Test Windows commands that depend on inherited handles, console attachment or nested child processes, using the merged series that includes d1de8cc6.
Public API
TExternalProcess.Startbehaviour-changed — The previously unavailable Windows backend now launches and supervises processes.
4
Medium
POSIX child startup no longer scans the full descriptor limit
When close_range or closefrom is unavailable, mormot.core.os.posix now inspects /proc/self/fd on Linux or /dev/fd elsewhere before fork. The child closes descriptors only through the highest observed descriptor plus a margin of 64, rather than looping to RLIMIT_NOFILE. A regression test places a descriptor far above the others and confirms that the child neither inherits it nor delays its closure.
Performance
mormot.core.os.posix
fa95d0f3+84-2
core: TExternalProcess child closes descriptors up to the highest opened - see #648
Impact
FPC and Delphi POSIX services with large file-descriptor limits avoid a launch-time cost on every TExternalProcess or RunRedirect call. The measured case drops from 118 ms at 524288 descriptors and 230 ms at 1048576 descriptors to about 1.3 ms on Linux, and from 33 ms to 6 ms on a macOS runner. Descriptor isolation remains intact.
Upgrade recommended
Pull this fix if a POSIX backend launches commands after TPollSockets raises RLIMIT_NOFILE, especially on macOS or Linux before close_range support.
Units
5
Medium
Delphi POSIX receives the process and signal wrappers needed for redirection
mormot.core.os.delphi publishes wrappers and types for pipes, dup2, fcntl, waitpid and POSIX signal operations. The conditional split that left TExternalProcess and RunRedirect as Delphi POSIX stubs is removed, so the shared mormot.core.os.posix implementation is compiled for Delphi. Linux Delphi calls libc pipe2, while close_range remains FPC-only to avoid requiring glibc 2.34. Tests are enabled for Delphi POSIX except the SIGUSR1 sender. The commit explicitly says it had not yet been compiled with a Delphi POSIX compiler.
Compiler & platform
mormot.core.os+2
8c07aafe+116-94
core: TExternalProcess and RunRedirect() on Delphi POSIX - see #648
Impact
Delphi Linux and macOS applications gain the same external-process surface as FPC, including environment-aware RunRedirect and TExternalProcess stream control. This exact revision is provisional: the next commit fixes unsigned THandle descriptors and a PosChar type mismatch found by Delphi 13 Linux64, so it should not be used as a landing point.
Worth a look
Review Delphi POSIX code that previously worked around missing RunRedirect features, but test only the follow-up 1d5b3085 or the merged PR #734 result.
Public API
TFilDes/TSigSet/SigactionRecadded — Delphi POSIX types needed by the shared process implementation.fppipe/fpdup2/fpfcntl/fpwaitpid/wifexited/wexitstatusadded — Published Delphi wrappers matching the FPC-style POSIX calls.fpsigemptyset/fpsigprocmask/fpsigactionadded — Published signal wrappers used around fork and exec.RunRedirectbehaviour-changed — Delphi POSIX now uses the shared implementation instead of returning an unimplemented error.TExternalProcess.Startbehaviour-changed — Delphi POSIX now enters the real process-launch path instead of the stub.
6
Medium
Signed POSIX descriptors make TExternalProcess compile on Delphi Linux
mormot.core.os changes the protected stdin, stdout, stderr and wake-up descriptor fields from THandle to integer on POSIX, preserving -1 as the invalid value even though Delphi defines THandle as unsigned there. NO_HANDLE follows the same conditional type. mormot.core.os.posix also casts the command name to PUtf8Char before calling PosChar. The author compiled and ran _RunRedirect and _TExternalProcess with Delphi 13 Linux64 on Debian 11.
Compiler & platform
mormot.core.os+1
1d5b3085+5-3
core: TExternalProcess compiles with the Delphi Linux compiler - see #648
Impact
Delphi Linux64 can compile the new external-process implementation and correctly recognize closed descriptors. Without this fix, the preceding Delphi POSIX enablement does not compile cleanly and its -1 validity checks are type-incompatible. FPC POSIX behavior is unchanged.
Upgrade recommended
Use at least 1d5b3085 when enabling TExternalProcess or the new RunRedirect path with Delphi Linux; do not stop on 8c07aafe.
7
Low
The signal-interruption test tolerates slower macOS runners
TTestCoreBase._RunRedirect lowers the required number of SIGUSR1 deliveries during a one-second command from more than ten to at least three. The assertion still proves that RunRedirect survives repeated signals, while allowing for macOS arm64 runners whose sender thread wakes roughly every 100 ms instead of every 20 ms.
Tests
96554b8e+2-1
test: TTestCoreBase._RunRedirect expects fewer signals - see #648
Impact
There is no application-code or runtime behavior change for Delphi or FPC backends. Continuous integration is less likely to report a false failure on slow macOS arm64 hosts.