Module Name: src
Committed By: kamil
Date: Fri Mar 6 17:03:35 UTC 2020
Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.h
Log Message:
Add await_collected()
This functions waits for collecting a process.
To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/tests/lib/libc/sys/t_ptrace_wait.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/lib/libc/sys/t_ptrace_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_wait.h:1.23 src/tests/lib/libc/sys/t_ptrace_wait.h:1.24
--- src/tests/lib/libc/sys/t_ptrace_wait.h:1.23 Tue Mar 3 17:09:22 2020
+++ src/tests/lib/libc/sys/t_ptrace_wait.h Fri Mar 6 17:03:35 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: t_ptrace_wait.h,v 1.23 2020/03/03 17:09:22 kamil Exp $ */
+/* $NetBSD: t_ptrace_wait.h,v 1.24 2020/03/06 17:03:35 kamil Exp $ */
/*-
* Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -463,6 +463,33 @@ await_stopped_child(pid_t process)
return child;
}
+static void __used
+await_collected(pid_t process)
+{
+ struct kinfo_proc2 p;
+ size_t len = sizeof(p);
+
+ const int name[] = {
+ [0] = CTL_KERN,
+ [1] = KERN_PROC2,
+ [2] = KERN_PROC_PID,
+ [3] = process,
+ [4] = sizeof(p),
+ [5] = 1
+ };
+
+ const size_t namelen = __arraycount(name);
+
+ /* Await the process to disappear */
+ while(1) {
+ FORKEE_ASSERT_EQ(sysctl(name, namelen, &p, &len, NULL, 0), 0);
+ if (len == 0)
+ break;
+
+ ATF_REQUIRE(usleep(1000) == 0);
+ }
+}
+
/* Happy number sequence -- this function is used to just consume cpu cycles */
#define HAPPY_NUMBER 1