Files
RedBear-OS/tests/unistd/fork.c
T
Red Bear OS 1b3e94a20d Red Bear OS relibc baseline
From release 0.1.0 pre-patched archive.
This includes all Red Bear modifications previously maintained
as patches in local/patches/relibc/.
2026-06-27 09:19:26 +03:00

31 lines
640 B
C

#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "test_helpers.h"
void prepare() {
puts("Hello from prepare");
}
void parent() {
// Make sure we print in the right order and also don't exit
// before the fork does.
int us_status = usleep(1000);
ERROR_IF(usleep, us_status, == -1);
UNEXP_IF(usleep, us_status, != 0);
puts("Hello from parent");
}
void child() {
puts("Hello from child");
}
int main(void) {
int status = pthread_atfork(prepare, parent, child);
ERROR_IF(pthread_atfork, status, == -1);
int pid = fork();
ERROR_IF(fork, pid, == -1);
}