#define _GNU_SOURCE #include #include #define PATH "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" int main(int argc, char** argv) { FILE* stream; char* line_buf = NULL; int line_cap = 0; int line_len; stream = fopen(PATH, "w"); if (stream == NULL) { perror("fopen"); return EXIT_FAILURE; } line_len = getline(&line_buf, &line_cap, stdin); if (line_len < 0) { perror("getline"); return EXIT_FAILURE; } if (fwrite(line_buf, line_len, 1, stream) != 1) { perror("fwrite"); return EXIT_FAILURE; } if (fclose(stream) == EOF) { perror("fclose"); return EXIT_FAILURE; } free(line_buf); return EXIT_SUCCESS; } /* vim: set ts=4 sts=4 sw=4 tw=80 et: */