7 /* Should see 3 threads exiting in different ways, all holding one (or
10 pthread_mutex_t mxC1
= PTHREAD_MUTEX_INITIALIZER
;
11 pthread_mutex_t mxC2
= PTHREAD_MUTEX_INITIALIZER
;
12 pthread_mutex_t mxC2b
= PTHREAD_MUTEX_INITIALIZER
;
13 pthread_mutex_t mxP
= PTHREAD_MUTEX_INITIALIZER
;
15 /* This one exits in the normal way, by joining back */
16 void* child_fn1 ( void* arg
)
18 int r
= pthread_mutex_lock( &mxC1
); assert(!r
);
22 /* This one detaches, does its own thing. */
23 void* child_fn2 ( void* arg
)
26 r
= pthread_mutex_lock( &mxC2
); assert(!r
);
27 r
= pthread_mutex_lock( &mxC2b
); assert(!r
);
28 r
= pthread_detach( pthread_self() ); assert(!r
);
32 /* Parent creates 2 children, takes a lock, waits, segfaults. Use
33 sleeps to enforce exit ordering, for repeatable regtesting. */
37 pthread_t child1
, child2
;
39 r
= pthread_create(&child2
, NULL
, child_fn2
, NULL
); assert(!r
);
42 r
= pthread_create(&child1
, NULL
, child_fn1
, NULL
); assert(!r
);
43 r
= pthread_join(child1
, NULL
); assert(!r
);
46 r
= pthread_mutex_lock( &mxP
);
48 kill( getpid(), SIGABRT
);