Core::System::waitpid serenityos c++ system call - c++ first see.
#include <LibCore/System.h> int main(int argc, char * argv[]) { bool enable_wait = false; if (argc == 2 && "true"sv == argv[1]) enable_wait = true; auto id = Core::System::fork(); if (id.value() == 0) { for (int i=0; i<5; ++i) AK::outln("[child] I am child"); } if (id.value() > 0) { if (enable_wait) { auto result = Core::System::waitpid(id.value(), 0); AK::outln("[parent] wait has error: {}", result.is_error()); AK::outln("[parent] wait child: {}, wait result: {}", result.value().pid, result.value().status); } AK::outln("[parent] I am parent, my child is {}", id); for (int i=0; i<5; ++i) { AK::outln("[parent] I am parent"); } } }
output (not enable):
courage:~ $ ./hello [parent] I am parent, my child is {3579} [parent] I am parent [parent] I am parent [parent] I am parent [parent] I am parent [parent] I am parent [child] I am child [child] I am child [child] I am child [child] I am child [child] I am child
output (enable):
courage:~ $ ./hello true [child] I am child [child] I am child [child] I am child [child] I am child [child] I am child [parent] wait has error: false [parent] wait child: 3643, wait result: 0 [parent] I am parent, my child is {3643} [parent] I am parent [parent] I am parent [parent] I am parent [parent] I am parent [parent] I am parent
Jan 20, 2025
c++ std::exception:
std::cout.write(err.data(), err.size());
std::cout << std::endl;
caught:
=================================== # The c++ programming language. # # # # Join c++ Discord: yZcauUAUyC # # Deck # ===================================