Lines Matching refs:child

37 struct child {  struct
46 static void release_child(struct child *child) in release_child() argument
50 if (!child) in release_child()
52 close(child->go[1]); in release_child()
53 close(child->go[0]); in release_child()
54 if (child->thread) in release_child()
55 pthread_join(child->thread, NULL); in release_child()
56 close(child->c2p[0]); in release_child()
57 close(child->c2p[1]); in release_child()
58 if (child->pid > 0) in release_child()
59 waitpid(child->pid, &child_status, 0); in release_child()
62 static void kick_child(struct child *child) in kick_child() argument
66 if (child) { in kick_child()
67 write(child->go[1], &c, 1); in kick_child()
68 release_child(child); in kick_child()
75 struct child *child = arg; in child_func() local
78 close(child->go[1]); in child_func()
81 err = read(child->go[0], &c, 1); in child_func()
93 static int spawn_child_flag(struct child *child, bool clone_vm) in spawn_child_flag() argument
96 if (pipe(child->go)) in spawn_child_flag()
100 child->pid = child->tid = clone(child_func, child->stack + sizeof(child->stack)/2, in spawn_child_flag()
101 CLONE_VM|SIGCHLD, child); in spawn_child_flag()
103 child->pid = child->tid = fork(); in spawn_child_flag()
105 if (child->pid < 0) { in spawn_child_flag()
106 release_child(child); in spawn_child_flag()
112 if (!clone_vm && child->pid == 0) in spawn_child_flag()
113 child_func(child); in spawn_child_flag()
118 static int spawn_child(struct child *child) in spawn_child() argument
120 return spawn_child_flag(child, false); in spawn_child()
125 struct child *child = ctx; in child_thread() local
128 child->tid = syscall(SYS_gettid); in child_thread()
131 err = write(child->c2p[1], &c, 1); in child_thread()
136 err = read(child->go[0], &c, 1); in child_thread()
149 static int spawn_thread(struct child *child) in spawn_thread() argument
154 if (pipe(child->go)) in spawn_thread()
157 if (pipe(child->c2p)) { in spawn_thread()
158 close(child->go[0]); in spawn_thread()
159 close(child->go[1]); in spawn_thread()
163 child->pid = getpid(); in spawn_thread()
165 err = pthread_create(&child->thread, NULL, child_thread, child); in spawn_thread()
168 close(child->go[0]); in spawn_thread()
169 close(child->go[1]); in spawn_thread()
170 close(child->c2p[0]); in spawn_thread()
171 close(child->c2p[1]); in spawn_thread()
176 err = read(child->c2p[0], &c, 1); in spawn_thread()
183 static void uprobe_multi_test_run(struct uprobe_multi *skel, struct child *child) in uprobe_multi_test_run() argument
196 skel->bss->pid = child ? 0 : getpid(); in uprobe_multi_test_run()
197 skel->bss->expect_pid = child ? child->pid : 0; in uprobe_multi_test_run()
204 if (!child || !child->thread) { in uprobe_multi_test_run()
211 if (child) in uprobe_multi_test_run()
212 kick_child(child); in uprobe_multi_test_run()
230 if (child) { in uprobe_multi_test_run()
231 ASSERT_EQ(skel->bss->child_pid, child->pid, "uprobe_multi_child_pid"); in uprobe_multi_test_run()
232 ASSERT_EQ(skel->bss->child_tid, child->tid, "uprobe_multi_child_tid"); in uprobe_multi_test_run()
257 struct child *child) in __test_attach_api() argument
259 pid_t pid = child ? child->pid : -1; in __test_attach_api()
307 uprobe_multi_test_run(skel, child); in __test_attach_api()
310 if (child) { in __test_attach_api()
311 ASSERT_EQ(skel->bss->child_pid_usdt, child->pid, "usdt_multi_child_pid"); in __test_attach_api()
312 ASSERT_EQ(skel->bss->child_tid_usdt, child->tid, "usdt_multi_child_tid"); in __test_attach_api()
321 static struct child child; in test_attach_api() local
327 if (!ASSERT_OK(spawn_child(&child), "spawn_child")) in test_attach_api()
330 __test_attach_api(binary, pattern, opts, &child); in test_attach_api()
333 if (!ASSERT_OK(spawn_thread(&child), "spawn_thread")) in test_attach_api()
336 __test_attach_api(binary, pattern, opts, &child); in test_attach_api()
648 static void __test_link_api(struct child *child) in __test_link_api() argument
670 opts.uprobe_multi.pid = child ? child->pid : 0; in __test_link_api()
707 uprobe_multi_test_run(skel, child); in __test_link_api()
727 static struct child child; in test_link_api() local
733 if (!ASSERT_OK(spawn_child(&child), "spawn_child")) in test_link_api()
736 __test_link_api(&child); in test_link_api()
739 if (!ASSERT_OK(spawn_thread(&child), "spawn_thread")) in test_link_api()
742 __test_link_api(&child); in test_link_api()
971 struct child child[TASKS] = {}; in run_pid_filter() local
977 if (!ASSERT_OK(spawn_child_flag(&child[i], clone_vm), "spawn_child")) in run_pid_filter()
979 skel->bss->pids[i] = child[i].pid; in run_pid_filter()
984 child[i].pid, "/proc/self/exe", in run_pid_filter()
991 kick_child(&child[i]); in run_pid_filter()
1002 release_child(&child[i]); in run_pid_filter()