cpuinfo.c 548 B

123456789101112131415161718192021222324
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. #define _GNU_SOURCE
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <errno.h>
  7. int main (int argc, char ** argv)
  8. {
  9. FILE * cpuinfo = fopen("/proc/cpuinfo", "rb");
  10. char * arg = 0;
  11. size_t size = 0;
  12. if (!cpuinfo)
  13. return errno;
  14. while(getdelim(&arg, &size, 0, cpuinfo) != -1)
  15. puts(arg);
  16. free(arg);
  17. fclose(cpuinfo);
  18. return 0;
  19. }