Issue
i used "psinfo_t" struct for printing cpu usage, start time of the processes in Solaris. But our companie's server was moved to Linux(Red Hat Linux), so i can't compile my c code because it has psinfo_t struct. where can i find that?
Solution
On Solaris (proc(5)), psinfo_t is a type found in <procfs.h>.
This does not exist on Linux, and the two /proc filesystems have various differences.
Under Linux (proc(5)), /proc/[pid]/stat contains the usual information found with ps(1).
Here is the simplest of examples, printing information about the current process.
#include <stdio.h>
int main(void) {
    FILE *self = fopen("/proc/self/stat", "r");
    char buffer[512];
    while (fgets(buffer, sizeof buffer, self))
        printf("%s", buffer);
    fclose(self);
}
Answered By - Oka Answer Checked By - David Goodson (PHPFixing Volunteer)
 
 Posts
Posts
 
 
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.