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

cpp/c++

c++ std::exception:

std::cout.write(err.data(), err.size());

std::cout << std::endl;

caught:

  ===================================
  #  The c++ programming language.  #
  #                                 #
  #  Join c++ Discord: yZcauUAUyC   #
  #  Deck                           #
  ===================================

Home: cppfx.xyz


PrevUpHomeNext