2 * Copyright (c) 2015-2018 Dmitry V. Levin <ldv@altlinux.org>
5 * SPDX-License-Identifier: GPL-2.0-or-later
16 logit_(const char *const str)
21 #define prefix "fork-f."
22 #define logit(arg) logit_(prefix arg)
24 int main(int ac, char **av)
33 int child_wait_fds[2];
35 if (pipe(child_wait_fds))
36 perror_msg_and_fail("pipe");
41 perror_msg_and_fail("fork");
44 close(child_wait_fds[1]);
46 if (read(0, child_wait_fds, sizeof(int)))
49 char *const args[] = { av[0], (char *) "", NULL };
50 if (logit("child") || execve(args[0], args, args + 1))
57 close(child_wait_fds[1]);
60 assert(wait(&status) == pid);
63 pid_t ppid = getpid();
66 printf("%-5d chdir(\"%sstart\") = -1 ENOENT (%m)\n"
67 "%-5d chdir(\"%sparent\") = -1 ENOENT (%m)\n"
68 "%-5d chdir(\"%schild\") = -1 ENOENT (%m)\n"
69 "%-5d chdir(\"%sexec\") = -1 ENOENT (%m)\n"
70 "%-5d chdir(\"%sfinish\") = -1 ENOENT (%m)\n",