Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/trace.ml
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,18 @@ module Make_commands (Backend : Backend_intf.S) = struct
and backend_opts = Backend.Record_opts.param
and collection_mode = Collection_mode.param in
fun ~executable ~f ->
let cleanup_record_dir record_dir =
match%map Monitor.try_with (fun () ->
Shell.rm ~r:() ~f:() record_dir;
Deferred.unit)
with
| Ok () -> ()
| Error exn ->
eprintf
"[ Warning: failed to remove temporary working directory %s: %s ]\n%!"
record_dir
(Exn.to_string exn)
in
let record_dir, cleanup =
match record_dir with
| Some dir ->
Expand All @@ -581,8 +593,7 @@ module Make_commands (Backend : Backend_intf.S) = struct
in
Monitor.protect
~finally:(fun () ->
if cleanup then Shell.rm ~r:() ~f:() record_dir;
Deferred.unit)
if cleanup then cleanup_record_dir record_dir else Deferred.unit)
(fun () ->
f
{ Record_opts.backend_opts
Expand Down