apio
bc07cc94cb
All checks were successful
continuous-integration/drone/push Build is passing
Also, add copyright information to individual files. This is going to be a hassle to do for EVERY file.
62 lines
2.4 KiB
C++
62 lines
2.4 KiB
C++
/**
|
|
* @file Process.h
|
|
* @author apio (cloudapio.eu)
|
|
* @brief Functions to manipulate processes.
|
|
*
|
|
* @copyright Copyright (c) 2023, the Luna authors.
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
#include <luna/Result.h>
|
|
#include <luna/String.h>
|
|
#include <sys/types.h>
|
|
|
|
namespace os
|
|
{
|
|
/**
|
|
* @brief An object representing a process.
|
|
*/
|
|
class Process
|
|
{
|
|
public:
|
|
/**
|
|
* @brief Create a new process, which is an identical copy of the current one.
|
|
*
|
|
* @return Result<pid_t> The child's process ID in the parent process, and 0 in the child process.
|
|
*/
|
|
static Result<pid_t> fork();
|
|
|
|
/**
|
|
* @brief Replace the current process's executable with another one.
|
|
*
|
|
* @param path The new executable's path.
|
|
* @param args The argument list to pass to the new executable.
|
|
* @param search_in_path Determines whether to search in the system binary directories if path is just a name.
|
|
* @return Result<void> Always an error, as this function does not return on success.
|
|
*/
|
|
static Result<void> exec(StringView path, Slice<String> args, bool search_in_path = true);
|
|
|
|
/**
|
|
* @brief Replace the current process's executable with another one.
|
|
*
|
|
* @param path The new executable's path.
|
|
* @param args The argument list to pass to the new executable.
|
|
* @param search_in_path Determines whether to search in the system binary directories if path is just a name.
|
|
* @return Result<void> Always an error, as this function does not return on success.
|
|
*/
|
|
static Result<void> exec(StringView path, Slice<StringView> args, bool search_in_path = true);
|
|
|
|
/**
|
|
* @brief Replace the current process's executable with another one.
|
|
*
|
|
* @param path The new executable's path.
|
|
* @param args The argument list to pass to the new executable.
|
|
* @param env The environment to pass to the new executable, instead of the current environment.
|
|
* @param search_in_path Determines whether to search in the system binary directories if path is just a name.
|
|
* @return Result<void> Always an error, as this function does not return on success.
|
|
*/
|
|
static Result<void> exec(StringView path, Slice<String> args, Slice<String> env, bool search_in_path = true);
|
|
};
|
|
}
|