cpuinfo.c 383 B

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