b63256e69b
* bjm.c: Fix tabulation (such as extra spaces before tabs), convert punctuation where it deviates from prevalent form elsewhere in strace code, convert sizeof and offsetof where it deviates from from prevalent form, remove space between function/macro/array names and (parameters) or [index], add space between "if" and (condition), correct non-standard or wrong indentaion. * defs.h: Likewise * desc.c: Likewise * file.c: Likewise * ipc.c: Likewise * linux/arm/syscallent.h: Likewise * linux/avr32/syscallent.h: Likewise * linux/hppa/syscallent.h: Likewise * linux/i386/syscallent.h: Likewise * linux/ioctlsort.c: Likewise * linux/m68k/syscallent.h: Likewise * linux/microblaze/syscallent.h: Likewise * linux/powerpc/syscallent.h: Likewise * linux/s390/syscallent.h: Likewise * linux/s390x/syscallent.h: Likewise * linux/sh/syscallent.h: Likewise * linux/sh64/syscallent.h: Likewise * linux/tile/syscallent.h: Likewise * linux/x86_64/syscallent.h: Likewise * mem.c: Likewise * net.c: Likewise * pathtrace.c: Likewise * process.c: Likewise * signal.c: Likewise * sock.c: Likewise * strace.c: Likewise * stream.c: Likewise * sunos4/syscall.h: Likewise * sunos4/syscallent.h: Likewise * svr4/syscall.h: Likewise * svr4/syscallent.h: Likewise * syscall.c: Likewise * system.c: Likewise * test/childthread.c: Likewise * test/leaderkill.c: Likewise * test/skodic.c: Likewise * time.c: Likewise * util.c: Likewise Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
65 lines
1.2 KiB
C
65 lines
1.2 KiB
C
/* Test handle_group_exit() handling of a thread leader still alive with its
|
|
* thread child calling exit_group() and proper passing of the process exit
|
|
* code to the process parent of this whole thread group.
|
|
*
|
|
* gcc -o test/leaderkill test/leaderkill.c -Wall -ggdb2 -pthread;./test/leaderkill & pid=$!;sleep 1;strace -o x -q ./strace -f -p $pid
|
|
* It must print: write(1, "OK\n", ...
|
|
*/
|
|
|
|
#include <pthread.h>
|
|
#include <assert.h>
|
|
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <sys/wait.h>
|
|
|
|
static void *start0(void *arg)
|
|
{
|
|
sleep(1);
|
|
exit(42);
|
|
}
|
|
|
|
static void *start1(void *arg)
|
|
{
|
|
pause();
|
|
/* NOTREACHED */
|
|
assert(0);
|
|
}
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
pthread_t thread0;
|
|
pthread_t thread1;
|
|
pid_t child, got_pid;
|
|
int status;
|
|
int i;
|
|
|
|
sleep(2);
|
|
|
|
child = fork();
|
|
|
|
switch (child) {
|
|
case -1:
|
|
abort();
|
|
case 0:
|
|
i = pthread_create(&thread0, NULL, start0, NULL);
|
|
assert(i == 0);
|
|
i = pthread_create(&thread1, NULL, start1, NULL);
|
|
assert(i == 0);
|
|
pause();
|
|
/* NOTREACHED */
|
|
assert(0);
|
|
break;
|
|
default:
|
|
got_pid = waitpid(child, &status, 0);
|
|
assert(got_pid == child);
|
|
assert(WIFEXITED(status));
|
|
assert(WEXITSTATUS(status) == 42);
|
|
puts("OK");
|
|
exit(0);
|
|
}
|
|
|
|
/* NOTREACHED */
|
|
abort();
|
|
}
|