summaryrefslogtreecommitdiff
path: root/test/childthread.c
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2009-02-25 14:24:02 +0000
committerDenys Vlasenko <dvlasenk@redhat.com>2009-02-25 14:24:02 +0000
commit8ed57276426392f961d557ea0bf54d9ba6ac4a5f (patch)
treec1acf8718735dbc42a420f5fb41eca364f86eff1 /test/childthread.c
parent4dedd561d61562fe66f1a0b673ad33ac6a1e3c71 (diff)
downloadstrace-8ed57276426392f961d557ea0bf54d9ba6ac4a5f.tar.gz
strace-8ed57276426392f961d557ea0bf54d9ba6ac4a5f.tar.bz2
strace-8ed57276426392f961d557ea0bf54d9ba6ac4a5f.tar.xz
By Hans-Christian Egtvedt (hans-christian.egtvedt AT atmel.com):
strace.c: suppress "warning: unused static" message by adding #ifdef's around a variable .gitignore: trivial test/*.c: cleanup (suppress warnings, much better style).
Diffstat (limited to 'test/childthread.c')
-rw-r--r--test/childthread.c77
1 files changed, 39 insertions, 38 deletions
diff --git a/test/childthread.c b/test/childthread.c
index bd0174b..e89fb14 100644
--- a/test/childthread.c
+++ b/test/childthread.c
@@ -13,47 +13,48 @@
#include <stdio.h>
#include <sys/wait.h>
-static void *start0 (void *arg)
+static void *start0(void *arg)
{
- pause ();
- /* NOTREACHED */
- assert (0);
+ pause();
+ /* NOTREACHED */
+ assert(0);
}
-int main (void)
+int main(int argc, char *argv[])
{
- pthread_t thread0;
- int i;
- pid_t child, got_pid;
- int status;
+ pthread_t thread0;
+ pid_t child, got_pid;
+ int status;
+ int i;
- child = fork ();
- switch (child)
- {
- case -1:
- assert (0);
- case 0:
- i = pthread_create (&thread0, NULL, start0, NULL);
- assert (i == 0);
- /* The thread must be initialized, it becomes thread-child of this
- process-child (child of a child of the toplevel process). */
- sleep (1);
- /* Here the child TCB cannot be deallocated as there still exist
- * children (the thread child in START0). */
- exit (42);
- /* NOTREACHED */
- assert (0);
- default:
- /* We must not be waiting in WAITPID when the child double-exits. */
- sleep (2);
- /* PID must be -1. */
- got_pid = waitpid (-1, &status, 0);
- assert (got_pid == child);
- assert (WIFEXITED (status));
- assert (WEXITSTATUS (status) == 42);
- puts ("OK");
- exit (0);
- }
- /* NOTREACHED */
- assert (0);
+ child = fork();
+
+ switch(child) {
+ case -1:
+ assert(0);
+ case 0:
+ i = pthread_create(&thread0, NULL, start0, NULL);
+ assert(i == 0);
+ /* The thread must be initialized, it becomes thread-child of this
+ process-child (child of a child of the toplevel process). */
+ sleep(1);
+ /* Here the child TCB cannot be deallocated as there still exist
+ * children (the thread child in START0). */
+ exit(42);
+ /* NOTREACHED */
+ assert(0);
+ default:
+ /* We must not be waiting in WAITPID when the child double-exits. */
+ sleep(2);
+ /* PID must be -1. */
+ got_pid = waitpid(-1, &status, 0);
+ assert(got_pid == child);
+ assert(WIFEXITED(status));
+ assert(WEXITSTATUS(status) == 42);
+ puts("OK");
+ exit(0);
+ }
+
+ /* NOTREACHED */
+ assert(0);
}