See for example write_temp_file_with_autodelete in libs/commons/UTmp.ml. In general it seems there can be races if one uses Filename.open_temp_filesince two domains could be selecting the same ...