Skip to content

process process

Alairion edited this page May 8, 2021 · 2 revisions

nes::process::process

Functions

(1) constexpr process() noexcept = default;
(2) explicit process(const std::string& path, const std::string& working_directory);
(3) explicit process(const std::string& path, process_options options);
(4) explicit process(const std::string& path, const std::vector<std::string>& args, process_options options);
(5) explicit process(const std::string& path, const std::string& working_directory, process_options options);
(6) explicit process(const std::string& path, std::vector<std::string> args = std::vector<std::string>{}, const std::string& working_directory = std::string{}, process_options options = process_options{});
(7) process(const process&) = delete;
(8) process(process&& other) noexcept;
  1. Constructs a new process object which does not represent a process.
  2. Delegates construction to (6) by calling process{path, {}, working_directory, {}}.
  3. Delegates construction to (6) by calling process{path, {}, {}, options}.
  4. Delegates construction to (6) by calling process{path, args, {}, options}.
  5. Delegates construction to (6) by calling process{path, {}, working_directory, options}.
  6. Constructs a new process object that represents a new process that is an image of the file located at path. args is a vector of strings that is given to the child process main function. working_directory is the child working directory. options are additional flags which change the behaviour of the process creation.
  7. Deleted copy-constructor.
  8. Move constructor. Initializes the new process with the content other. After this call, other does no longer represents a valid process.

Parameters

Name Description
path An UTF-8 encoded string that represents the relative or absolute path where the executable file is located
args If args is not empty, the child process will received args.size() + 1 arguments where the first one is path, otherwise the child process will received only one argument, which is path. Each string in args is an UTF-8 encoded string
working_directory An UTF-8 encoded string that represents the relative or absolute path of the working directory of the child process. If working_directory is empty, the child's working directory is the same as the parent's
options A combination of value of the nes::process_options enum

Complexity

  1. Explicit
  2. Explicit
  3. Explicit
  4. Explicit
  5. Explicit

Exceptions

  1. Does not throw.
  2. See (6)
  3. See (6)
  4. See (6)
  5. See (6)
  6. May throw a std::runtime_error if the process creation failed.
  7. Deleted
  8. Does not throw

Implementation details

  1. On Windows, the process is created using CreateProcessW
    On Posix systems, the process is created using fork or vfork (if possible) followed by exec
Clone this wiki locally