I've tried using functions(proc_pidinfo) from the library <libproc.h> but it appears that it cannot be done for root processes. I'm kind of a newbie, so I'm trying to understand is there any way to get information(CPU time for instance) programmatically from root processes.
Get process information from root processes
So I asked on stackexchange and turns out all you have to do is run the code in sudo. For Xcode. Get the executable file. And then in the terminal cd (path to executable). Finally, in the terminal sudo ./yourexecutablefilename