mirror of
https://github.com/FeralInteractive/gamemode.git
synced 2025-08-07 05:38:30 +02:00
external-helper: improve run_external_process() robustness
run_external_process() contained pipe file descriptors leaks (e.g. one pipe end was never closed). Also the stdout might have been captured incomplete, since only a single read() was performed on the pipe. Furthermore should a child process try to write a larger amount of data onto the pipe then it will become stuck, because the parent process isn't consuming the data. Thus the timeout would trigger in these cases although the child process does nothing wrong. This commit changes the implementation to follow a select() based approach that continually reads from the pipe, but discards data that doesn't fit in the provided buffer.
This commit is contained in:
@@ -67,7 +67,7 @@ static void print_usage_and_exit(void)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static const char* get_nv_attr(const char *attr)
|
||||
static const char *get_nv_attr(const char *attr)
|
||||
{
|
||||
static char out[EXTERNAL_BUFFER_MAX];
|
||||
const char *exec_args[] = { "/usr/bin/nvidia-settings", "-q", attr, "-t", NULL };
|
||||
@@ -315,8 +315,7 @@ static int get_gpu_state_amd(struct GameModeGPUInfo *info)
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
if( ret == 0 )
|
||||
{
|
||||
if (ret == 0) {
|
||||
/* Copy in the value from the file */
|
||||
strncpy(info->amd_performance_level, buff, CONFIG_VALUE_MAX - 1);
|
||||
info->amd_performance_level[CONFIG_VALUE_MAX - 1] = '\0';
|
||||
|
Reference in New Issue
Block a user