diff options
author | Robert Collins <rbtcollins@hotmail.com> | 2002-11-24 13:41:36 +0000 |
---|---|---|
committer | Robert Collins <rbtcollins@hotmail.com> | 2002-11-24 13:41:36 +0000 |
commit | 4f0de34d3747d689cc741f045072486b0c602f15 (patch) | |
tree | e00685d966fc8c1a24267d3c810ab569d504c6ff /winsup/testsuite/winsup.api/pthread/threadidafterfork.c | |
parent | f29c4db1855efd6692bb564f474dc627747b1a80 (diff) | |
download | cygnal-4f0de34d3747d689cc741f045072486b0c602f15.tar.gz cygnal-4f0de34d3747d689cc741f045072486b0c602f15.tar.bz2 cygnal-4f0de34d3747d689cc741f045072486b0c602f15.zip |
2002-11-25 Robert Collins <rbtcollins@hotmail.com>
* readme: Document running portions of the test suite (Thanks Egor!).
* winsup.api/pthread/mainthreadexits.c: New file, derived from
Thomas Pfaff's test cases.
* winsup.api/pthread/threadidafterfork.c: Ditto.
Diffstat (limited to 'winsup/testsuite/winsup.api/pthread/threadidafterfork.c')
-rw-r--r-- | winsup/testsuite/winsup.api/pthread/threadidafterfork.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/winsup/testsuite/winsup.api/pthread/threadidafterfork.c b/winsup/testsuite/winsup.api/pthread/threadidafterfork.c new file mode 100644 index 000000000..da93a4d3f --- /dev/null +++ b/winsup/testsuite/winsup.api/pthread/threadidafterfork.c @@ -0,0 +1,49 @@ +#include <stdio.h> +#include <unistd.h> +#include <sys/wait.h> +#include <pthread.h> + +static void * TestThread ( void * ); + +int main (void) +{ + pthread_t t; + + pthread_create (&t, NULL, TestThread, NULL); + pthread_join (t, NULL); + + return 0; +} + +static void * TestThread ( void *not_used ) +{ + pthread_t iAm = pthread_self(); + int status; + switch (fork ()) + { + case -1: + exit(1); + case 0: + if (iAm != pthread_self()) + exit (1); + else + exit (0); + break; + default: + wait (&status); + if (status != 0) + exit (1); + } + exit(0); +} + +/* +The forked child will not get the same thread handle as its parent, it +will get the thread handle from the main thread instead. The child will +not terminate because the threadcount is still 2 after the fork (it is +set to 1 in MTinterface::Init and then set back to 2 after the childs +memory gets overwritten by the parent). + +concept test by Thomas Pfaff <tpfaff@gmx.net> +scritable test by Robert Collins <rbtcollins@hotmail.com> +*/ |