mirror of
https://github.com/FeralInteractive/gamemode.git
synced 2025-06-06 23:57:22 +02:00
cpugovctl: evaluate govenor write errors and adjust exit code accordingly
This commit is contained in:
parent
2896506340
commit
5f06435bdf
@ -35,15 +35,18 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets all governors to a value
|
* Sets all governors to a value
|
||||||
*/
|
*/
|
||||||
static void set_gov_state(const char *value)
|
static int set_gov_state(const char *value)
|
||||||
{
|
{
|
||||||
char governors[MAX_GOVERNORS][MAX_GOVERNOR_LENGTH] = { { 0 } };
|
char governors[MAX_GOVERNORS][MAX_GOVERNOR_LENGTH] = { { 0 } };
|
||||||
int num = fetch_governors(governors);
|
int num = fetch_governors(governors);
|
||||||
|
int retval = EXIT_SUCCESS;
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
LOG_MSG("Setting governors to %s\n", value);
|
LOG_MSG("Setting governors to %s\n", value);
|
||||||
for (int i = 0; i < num; i++) {
|
for (int i = 0; i < num; i++) {
|
||||||
@ -54,9 +57,15 @@ static void set_gov_state(const char *value)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(f, "%s\n", value);
|
res = fprintf(f, "%s\n", value);
|
||||||
|
if (res < 0) {
|
||||||
|
LOG_ERROR("Failed to set governor %s to %s: %s", gov, value, strerror(errno));
|
||||||
|
retval = EXIT_FAILURE;
|
||||||
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,7 +84,7 @@ int main(int argc, char *argv[])
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_gov_state(value);
|
return set_gov_state(value);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "usage: cpugovctl [get] [set VALUE]\n");
|
fprintf(stderr, "usage: cpugovctl [get] [set VALUE]\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user