Skip to content

Commit ef76c6d

Browse files
GuillaumeLagrangeart049
authored andcommitted
feat: remove existing pipedata file if there are any
1 parent a099620 commit ef76c6d

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

  • src/run/runner/wall_time/perf

src/run/runner/wall_time/perf/mod.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ impl PerfRunner {
9090
mut cmd_builder: CommandBuilder,
9191
config: &Config,
9292
) -> anyhow::Result<ExitStatus> {
93+
if Path::new(PERF_DATA_PATH).exists() {
94+
std::fs::rename(PERF_DATA_PATH, format!("{PERF_DATA_PATH}.old")).with_context(
95+
|| format!("Failed to move existing perf data file at {PERF_DATA_PATH}",),
96+
)?;
97+
}
98+
9399
let perf_fifo = PerfFifo::new()?;
94100
let runner_fifo = RunnerFifo::new()?;
95101

@@ -144,9 +150,11 @@ impl PerfRunner {
144150
"--",
145151
]);
146152
cmd_builder.wrap_with(perf_wrapper_builder);
147-
cmd_builder.args(["|", "cat", ">", PERF_DATA_PATH]);
148-
let cmd = wrap_with_sudo(cmd_builder)?.build();
149-
debug!("cmd: {cmd:?}");
153+
let raw_command = format!("{} | cat > PERF_DATA_PATH", &cmd_builder.as_command_line());
154+
let mut wrapped_builder = CommandBuilder::new("sh");
155+
wrapped_builder.args(["-c", &raw_command]);
156+
let cmd = wrap_with_sudo(wrapped_builder)?.build();
157+
println!("cmd: {cmd:?}");
150158

151159
let on_process_started = async |_| -> anyhow::Result<()> {
152160
let data = Self::handle_fifo(runner_fifo, perf_fifo).await?;

0 commit comments

Comments
 (0)