src/utils/process.cpp
/**
   * Forks a child process and executes the given lambda function in it.
   *
   * Processes spawned this way need to be waited on by the caller.
   */
Forks a child process and executes the given lambda function in it.
Processes spawned this way need to be waited on by the caller.
Forks a child process and executes the given lambda function in it . Processes spawned this way need to be waited on by the caller .
pid_t spawn_async(std::function<void()> const& lambda) {
    pid_t pid = fork();
    switch (pid) {
      case -1:
        throw runtime_error("fork_detached: Unable to fork: " + string(strerror(errno)));
      case 0:
        setsid();
        umask(0);
        redirect_stdio_to_dev_null();
        lambda();
        _Exit(0);
        break;
      default:
        return pid;
    }
  }
pid_t spawn_async ( std :: function < void ( ) > const & lambda ) { pid_t pid = fork ( ) ; switch ( pid ) { case -1 : throw runtime_error ( " " + string ( strerror ( errno ) ) ) ; case 0 : setsid ( ) ; umask ( 0 ) ; redirect_stdio_to_dev_null ( ) ; lambda ( ) ; _Exit ( 0 ) ; break ; default : return pid ; } }
Forks a child process and executes the given lambda function in it.
Forks a child process and executes the given lambda function in it .
// Child