BlinkenArea - GitList
Repositories
Blog
Wiki
uproctrace
Code
Commits
Branches
Tags
Search
Tree:
5488c13
Branches
Tags
master
uproctrace
liblwpttr
src
proc_begin.c
proc_end: add proc_cpu_time
Stefan Schuermans
commited
5488c13
at 2020-05-17 17:26:39
proc_begin.c
Blame
History
Raw
#include <liblwpttr/proc_begin.h> #include "cleaner.h" #include "event.h" #include "stringlist.h" #include "symlink.h" #include "timing.h" #include <lwproctrace.pb-c.h> #include <stdlib.h> #include <sys/types.h> #include <unistd.h> int lwpttr_proc_begin(void **data, size_t *size) { *data = NULL; *size = 0; lwpttr_cleaner_t *cleaner = lwpttr_cleaner_new(); if (! cleaner) { return -1; } struct _Lwproctrace__Timespec timestamp = LWPROCTRACE__TIMESPEC__INIT; timing_get_timestamp(×tamp); struct _Lwproctrace__ProcBegin proc_begin = LWPROCTRACE__PROC_BEGIN__INIT; proc_begin.pid = getpid(); proc_begin.has_ppid = 1; proc_begin.ppid = getppid(); if (symlink_read("/proc/self/exe", &proc_begin.exe, cleaner) != 0) { return -1; } if (symlink_read("/proc/self/cwd", &proc_begin.cwd, cleaner) != 0) { return -1; } if (stringlist_read("/proc/self/cmdline", &proc_begin.n_cmdline, &proc_begin.cmdline, cleaner) != 0) { return -1; } if (stringlist_read("/proc/self/environ", &proc_begin.n_environ, &proc_begin.environ, cleaner) != 0) { return -1; } struct _Lwproctrace__Event event = LWPROCTRACE__EVENT__INIT; event.timestamp = ×tamp; event.proc_begin = &proc_begin; return lwpttr_event_pack(&event, data, size, cleaner); }