PrevUpHomeNext

Core::System::fork - SereniyOS c++


core::System::fork SereninyOS c++ system call. - c++ first see

c++ example

#include <LibCore/System.h>
#include <concepts>

int main()
{
	auto id = Core::System::fork();

	static_assert(std::same_as<decltype(id), AK::ErrorOr<int, AK::Error>>);
	AK::outln("id.is_error(): {}", id.is_error()?"true":"false");

	if (id.value() == 0)
	{
		AK::outln("I am child process.");
	}

	if (id.value() > 0)
	{
		AK::outln("I am parent process. My child process id is {}", id);
	}

	if (id.value() < 0)
	{
		AK::outln("Core::System::fork error");
	}
}

output:

id.is_error(): false
I am parent process. My child process id is {2472}
id.is_error(): false
I am child process.













Jan 20, 2025

Back

Up

Role

Powered by - B2 Build | boost quickbook | I2Pd

====

cppfx.i2p

cppfxjjm5bgqx2cepvisfcy4zz4ystzxxh36mtuvqm2jp5g6rb7a.b32.i2p


PrevUpHomeNext