mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 22:21:09 +03:00

std.process.Config.preExecDelegate is just like std.process.Config.preExecFunction, but can capture an environment, for example: import core.sys.linux.sys.prctl : PR_SET_PDEATHSIG, prctl; import std.process : Config, execute; void runProgram(int pdeathsig) { execute( ["program"], config: Config( preExecDelegate: () @trusted => prctl(PR_SET_PDEATHSIG, pdeathsig, 0, 0, 0) != -1, ), ); } preExecFunction is retained for backwards compatibility. If both preExecFunction and preExecDelegate are given, both are called.
25 lines
786 B
Text
25 lines
786 B
Text
Add `std.process.Config.preExecDelegate`
|
|
|
|
$(LINK2 $(ROOT_DIR)phobos/std_process.html#.Config.preExecDelegate, `std.process.Config.preExecDelegate`)
|
|
is just like
|
|
$(LINK2 $(ROOT_DIR)phobos/std_process.html#.Config.preExecFunction, `std.process.Config.preExecFunction`),
|
|
but can capture an environment, for example:
|
|
|
|
-------
|
|
import core.sys.linux.sys.prctl : PR_SET_PDEATHSIG, prctl;
|
|
import std.process : Config, execute;
|
|
|
|
void runProgram(int pdeathsig)
|
|
{
|
|
execute(
|
|
["program"],
|
|
config: Config(
|
|
preExecDelegate: () @trusted =>
|
|
prctl(PR_SET_PDEATHSIG, pdeathsig, 0, 0, 0) != -1,
|
|
),
|
|
);
|
|
}
|
|
-------
|
|
|
|
`preExecFunction` is retained for backwards compatibility. If both
|
|
`preExecFunction` and `preExecDelegate` are given, both are called.
|