diff --git a/tests/test_tmpfn.h b/tests/test_tmpfn.h index a2dff984b0..ea849355dc 100644 --- a/tests/test_tmpfn.h +++ b/tests/test_tmpfn.h @@ -11,6 +11,7 @@ #ifndef KWIVER_TEST_TEST_TMPFN_H_ #define KWIVER_TEST_TEST_TMPFN_H_ +#include #include #include @@ -32,6 +33,10 @@ namespace testing { std::string temp_file_name( char const* prefix, char const* suffix ) { + // tempnam() is not necessarily thread-safe + static std::mutex mut; + std::lock_guard< std::mutex > lock( mut ); + auto const n = tempnam(".", prefix); auto const s = std::string(n); free(n);