cpuinfo.c 372 B

123456789101112131415161718192021
  1. #define _GNU_SOURCE
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <errno.h>
  5. int main (int argc, char ** argv)
  6. {
  7. FILE * cpuinfo = fopen("/proc/cpuinfo", "rb");
  8. char * arg = 0;
  9. size_t size = 0;
  10. if (!cpuinfo)
  11. return errno;
  12. while(getdelim(&arg, &size, 0, cpuinfo) != -1)
  13. puts(arg);
  14. free(arg);
  15. fclose(cpuinfo);
  16. return 0;
  17. }