xref: /haiku/src/tests/system/libroot/posix/abort_test.cpp (revision 21258e2674226d6aa732321b6f8494841895af5f)
1 /*
2  * Copyright 2009, Axel Dörfler, axeld@pinc-software.de.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include <OS.h>
8 
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <string.h>
12 
13 
14 static status_t
15 abort_thread(void*)
16 {
17 	snooze(50000);
18 	abort();
19 	return 0;
20 }
21 
22 
23 int
24 main(int argc, char** argv)
25 {
26 	thread_id thread = spawn_thread(&abort_thread, "abort test",
27 		B_NORMAL_PRIORITY, NULL);
28 	resume_thread(thread);
29 
30 	status_t status = wait_for_thread(thread, NULL);
31 	fprintf(stderr, "abort thread aborted: %s\n", strerror(status));
32 
33 	snooze(1000000LL);
34 	fprintf(stderr, "main exiting\n");
35 	return 0;
36 }
37