Commit a080b6e7 authored by Shaopeng Tan's avatar Shaopeng Tan Committed by Shuah Khan
Browse files

selftests/resctrl: Flush stdout file buffer before executing fork()



When a process has buffered output, a child process created by fork()
will also copy buffered output. When using kselftest framework,
the output (resctrl test result message) will be printed multiple times.

Add fflush() to flush out the buffered output before executing fork().

Reviewed-by: default avatarShuah Khan <skhan@linuxfoundation.org>
Reviewed-by: default avatarReinette Chatre <reinette.chatre@intel.com>
Signed-off-by: default avatarShaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent 1e359b6a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -167,6 +167,7 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type)
		return errno;
	}

	fflush(stdout);
	bm_pid = fork();

	/* Set param values for child thread which will be allocated bitmask
+1 −0
Original line number Diff line number Diff line
@@ -629,6 +629,7 @@ int resctrl_val(char **benchmark_cmd, struct resctrl_val_param *param)
	 * Fork to start benchmark, save child's pid so that it can be killed
	 * when needed
	 */
	fflush(stdout);
	bm_pid = fork();
	if (bm_pid == -1) {
		perror("# Unable to fork");
+1 −0
Original line number Diff line number Diff line
@@ -678,6 +678,7 @@ int filter_dmesg(void)
		perror("pipe");
		return ret;
	}
	fflush(stdout);
	pid = fork();
	if (pid == 0) {
		close(pipefds[0]);