# base::LaunchOptions
[base::LaunchOptions](https://source.chromium.org/chromium/chromium/src/+/main:base/process/launch.h;l=65;drc=bfba107ad8696b80b3ffc0a6a65fcc5b590f1372) is a container of options for launching a subprocess.
This is used in [base::LaunchProcess](https://source.chromium.org/chromium/chromium/src/+/main:base/process/launch.h;l=342;drc=bfba107ad8696b80b3ffc0a6a65fcc5b590f1372).
Let's see what values are contained.
In this note, we focus on POSIX platform.
## Overview
First, it contains [`environment`](https://source.chromium.org/chromium/chromium/src/+/main:base/environment.h;l=55;drc=8e78783dc1f7007bad46d657c9f332614e240fd8) parameter as [EnvironmentMap](https://source.chromium.org/chromium/chromium/src/+/main:base/environment.h;l=55;drc=8e78783dc1f7007bad46d657c9f332614e240fd8), a map from NaeivEnvironmentString to NativeEnvironmentString (std::string).
Environment value is refered to construct [`new_environ`](https://source.chromium.org/chromium/chromium/src/+/main:base/process/launch_posix.cc;l=303;drc=8e78783dc1f7007bad46d657c9f332614e240fd8) which is passed to the global param [`environ`](https://source.chromium.org/chromium/chromium/src/+/main:base/process/launch_posix.cc;l=67;drc=8e78783dc1f7007bad46d657c9f332614e240fd8) inside launch_posix.cc via [SetEnvironment](https://source.chromium.org/chromium/chromium/src/+/main:base/process/launch_posix.cc;l=81;drc=8e78783dc1f7007bad46d657c9f332614e240fd8).
[`fds_to_remap`](https://source.chromium.org/chromium/chromium/src/+/main:base/process/launch.h;l=189;drc=bfba107ad8696b80b3ffc0a6a65fcc5b590f1372) is a remap file descriptors according to propagate FDs into the child process.
It's stored as [FileHandleMappingVector](https://source.chromium.org/chromium/chromium/src/+/main:base/process/launch.h;l=60;drc=8e78783dc1f7007bad46d657c9f332614e240fd8), the vector of int, int pair.
For each fd in `fds_to_remap` and push it back to [`fd_shuffle`](https://source.chromium.org/chromium/chromium/src/+/main:base/process/launch_posix.cc;l=453-458;drc=8e78783dc1f7007bad46d657c9f332614e240fd8), a vector of [InjectionArc](https://source.chromium.org/chromium/chromium/src/+/main:base/posix/file_descriptor_shuffle.h;l=57;drc=8e78783dc1f7007bad46d657c9f332614e240fd8).
There are 2 `fd_shuffle1` and `fd_shuffle2`.
One is mutated by [ShuffleFileDescriptors](https://source.chromium.org/chromium/chromium/src/+/main:base/posix/file_descriptor_shuffle.h;l=80;drc=8e78783dc1f7007bad46d657c9f332614e240fd8) which performs the actions required to perform an injective multimapping.
The other is passed to [CloseSuperfluouseFds](https://source.chromium.org/chromium/chromium/src/+/main:base/process/launch_posix.cc;l=215;drc=8e78783dc1f7007bad46d657c9f332614e240fd8) which checks all file descriptor.
If the fd is none of STDIN, STDOUT, STDERR nor the one in `fd_shuffle`, it's closed by `close(fd)`.
For opened one, the input is obtained from [`strtol`](https://www.ibm.com/docs/ja/i/7.2?topic=lf-strtol-strtoll-convert-character-string-long-long-long-integer) to `endptr`.
We also have `kill_on_parent_death` which is a flag to set process death signal to SIGKILL, `real_path` to specify the executable file ijnstead of CommandLine.GetProgram and so on.
## PreExecDelegate
[PreExecDelegate](https://source.chromium.org/chromium/chromium/src/+/main:base/process/launch.h;l=69;drc=bfba107ad8696b80b3ffc0a6a65fcc5b590f1372) is used to define the call between fork and exec in the subprocess.
The only meaning full method is [RunAsyncSafe](https://source.chromium.org/chromium/chromium/src/+/main:base/process/launch.h;l=81;drc=bfba107ad8696b80b3ffc0a6a65fcc5b590f1372).
Note that this function must be async safe since a fork may happen while multiple threads were running.
If it is registered, RunAsyncSafe runs while [LaunchProcess](https://source.chromium.org/chromium/chromium/src/+/main:base/process/launch_posix.cc;l=495;drc=8e78783dc1f7007bad46d657c9f332614e240fd8) just before `execvp`.