phobos/changelog/std.process.Config.preExecDelegate.dd
chloekek 7a280a938e Add std.process.Config.preExecDelegate
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.
2024-04-26 12:38:38 +02:00

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.