xref: /haiku/src/tests/system/libroot/posix/user_thread_fork_test.cpp (revision 9969137ced542e48be6e36af02f86f76c3f2f7c3)
1*9969137cSJérôme Duval #include <errno.h>
2*9969137cSJérôme Duval #include <stdio.h>
3*9969137cSJérôme Duval #include <stdlib.h>
4*9969137cSJérôme Duval #include <string.h>
5*9969137cSJérôme Duval #include <unistd.h>
6*9969137cSJérôme Duval 
7*9969137cSJérôme Duval #include <OS.h>
8*9969137cSJérôme Duval 
9*9969137cSJérôme Duval #include "user_thread.h"
10*9969137cSJérôme Duval 
11*9969137cSJérôme Duval int
main()12*9969137cSJérôme Duval main()
13*9969137cSJérôme Duval {
14*9969137cSJérôme Duval 	pid_t child = fork();
15*9969137cSJérôme Duval 	if (child < 0) {
16*9969137cSJérôme Duval 		fprintf(stderr, "Error: fork() failed: %s\n", strerror(errno));
17*9969137cSJérôme Duval 		exit(1);
18*9969137cSJérôme Duval 	}
19*9969137cSJérôme Duval 
20*9969137cSJérôme Duval 	if (child > 0) {
21*9969137cSJérôme Duval 		// the parent process -- wait for the child to finish
22*9969137cSJérôme Duval 		status_t result;
23*9969137cSJérôme Duval 		wait_for_thread(child, &result);
24*9969137cSJérôme Duval 	}
25*9969137cSJérôme Duval 
26*9969137cSJérôme Duval 	struct user_thread *t = get_user_thread();
27*9969137cSJérôme Duval 	printf("defer_signals: %" B_PRId32 "\n", t->defer_signals);
28*9969137cSJérôme Duval 
29*9969137cSJérôme Duval 	return 0;
30*9969137cSJérôme Duval }
31