2 * Check handling of CLONE_PARENT'ed processes.
4 * Copyright (c) 2017 The strace developers.
7 * SPDX-License-Identifier: GPL-2.0-or-later
21 child(void *const arg)
26 #define child_stack_size (get_page_size() / 2)
29 extern int __clone2(int (*)(void *), void *, size_t, int, void *, ...);
30 # define clone(fn, child_stack, flags, arg) \
31 __clone2(fn, child_stack, child_stack_size, flags, arg)
37 const pid_t pid = clone(child, tail_alloc(child_stack_size),
38 CLONE_PARENT | SIGCHLD, 0);
40 perror_msg_and_fail("clone");
43 if (wait(&status) >= 0)
44 error_msg_and_fail("unexpected return code from wait");
49 perror_msg_and_fail("kill");
51 FILE *const fp = fdopen(3, "a");
53 perror_msg_and_fail("fdopen");
54 if (fprintf(fp, "%s: Exit of unknown pid %d ignored\n",
55 getenv("STRACE_EXE") ?: "strace", pid) < 0)
56 perror_msg_and_fail("fprintf");
58 puts("+++ exited with 0 +++");