File: wd.c

package info (click to toggle)
libgtop2 2.40.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 8,072 kB
  • sloc: ansic: 25,393; sh: 7,089; makefile: 418; perl: 268; xml: 179; sed: 16
file content (35 lines) | stat: -rw-r--r-- 560 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <glibtop.h>
#include <glibtop/procwd.h>

#include <glib.h>
#include <unistd.h>

int main(int argc, char **argv)
{
	pid_t pid;
	glibtop_proc_wd buf;
	char **dirs, **dir;

	if (argc < 2 || !(pid = strtoul(argv[1], NULL, 0)))
		pid = getpid();

	glibtop_init();

	dirs = glibtop_get_proc_wd(&buf, pid);

	g_print("Process %u:\n"
		" - root: '%s'\n"
		" - exe: '%s'\n"
		" - working directories:\n",
		(unsigned)pid, buf.root, buf.exe);

	for (dir = dirs; *dir; ++dir)
		g_print("   - '%s'\n", *dir);

	g_strfreev(dirs);

	glibtop_close();

	return 0;
}