7 static void get_ancestry_names(struct strvec *names)
9 #ifdef HAVE_PROCFS_LINUX
11 * NEEDSWORK: We could gather the entire pstree into an array to match
12 * functionality with compat/win32/trace2_win32_process_info.c.
13 * To do so, we may want to examine /proc/<pid>/stat. For now, just
14 * gather the immediate parent name which is readily accessible from
15 * /proc/$(getppid())/comm.
17 struct strbuf procfs_path = STRBUF_INIT;
18 struct strbuf name = STRBUF_INIT;
20 /* try to use procfs if it's present. */
21 strbuf_addf(&procfs_path, "/proc/%d/comm", getppid());
22 if (strbuf_read_file(&name, procfs_path.buf, 0)) {
23 strbuf_release(&procfs_path);
24 strbuf_trim_trailing_newline(&name);
25 strvec_push(names, strbuf_detach(&name, NULL));
30 /* NEEDSWORK: add non-procfs-linux implementations here */
33 void trace2_collect_process_info(enum trace2_process_info_reason reason)
35 if (!trace2_is_enabled())
38 /* someday we may want to write something extra here, but not today */
39 if (reason == TRACE2_PROCESS_INFO_EXIT)
42 if (reason == TRACE2_PROCESS_INFO_STARTUP) {
44 * NEEDSWORK: we could do the entire ptree in an array instead,
45 * see compat/win32/trace2_win32_process_info.c.
47 struct strvec names = STRVEC_INIT;
49 get_ancestry_names(&names);
56 trace2_cmd_ancestry(names.v);