General Purpose library for Freestanding C++ and POSIX systems
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

51 lines
1.0 KiB

#pragma once
#include "gp_config.hpp"
#include "gp/function.hpp"
#include "gp/indexed_array.hpp"
#include "gp/pointers.hpp"
#include "gp/vfs/file_description.hpp"
#include "gp/vfs/platforms/platform_autopicker.hpp"
#include <atomic>
namespace gp {
enum class process_status {
inactive = 0,
running = 1,
waiting = 2,
finished = 3,
zombie = 4
};
using pid_t = size_t;
struct process_data{
pid_t pid;
gp::function<void()> fn;
void* stack;
size_t stack_sz;
gp::process_status state;
std::atomic_bool is_running;
[[no_unique_address]] gp::specifics::platform_data specifics;
gp::indexed_array<gp::file_description*, gp_config::limits::max_fd_per_process> fds;
process_data(gp::function<void()> _fn, void* _stack, size_t _stack_sz)
: fn(_fn)
, stack(_stack)
, stack_sz(_stack_sz)
, state(gp::process_status::inactive)
, specifics(gp::buffer<char>{(char*)stack, stack_sz})
{}
process_data(process_data&& v)
: fn(v.fn)
, stack(v.stack)
, stack_sz(v.stack_sz)
, state(v.state)
, specifics(v.specifics)
{}
};
}