2 * Reads /proc/self/psinfo such that it can be tested whether Valgrind
3 * intercepts the system calls that access this pseudo-file.
12 static void test_psinfo(int op
, const char *label
,
17 printf("open for %s:\n", label
);
19 fd
= open(path
, O_RDONLY
);
25 printf("openat for %s:\n", label
);
27 fd
= openat(AT_FDCWD
, path
, O_RDONLY
);
35 ssize_t bytes
= read(fd
, &psinfo
, sizeof(psinfo
));
36 if (bytes
!= sizeof(psinfo
)) {
41 printf("fname: %s\n", psinfo
.pr_fname
);
42 printf("psargs: %s\n", psinfo
.pr_psargs
);
44 printf("argc: %d\n", psinfo
.pr_argc
);
46 char **argv
= (char **) psinfo
.pr_argv
;
47 for (i
= 0; i
< psinfo
.pr_argc
; i
++) {
48 printf("argv[%u]: %s\n", i
, argv
[i
]);
54 int main(int argc
, const char *argv
[])
57 snprintf(path
, sizeof(path
), "/proc/%ld/psinfo", (long int) getpid());
59 test_psinfo(0, "/proc/self/psinfo", "/proc/self/psinfo");
61 test_psinfo(0, "/proc/<pid>/psinfo", path
);
64 test_psinfo(1, "/proc/self/psinfo", "/proc/self/psinfo");
66 test_psinfo(1, "/proc/<pid>/psinfo", path
);