PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, November 10, 2022

[FIXED] where is psinfo_t struct in linux library?

 November 10, 2022     c, linux, redhat     No comments   

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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing