Skip to content

Commit bdfdbfb

Browse files
authored
Emit process ID in the filenames of byn* tempfiles (#1916)
Helps to avoid trampling each other when binaryen is called multiple times from emcc, for example.
1 parent 14a2869 commit bdfdbfb

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/passes/pass.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
#include <chrono>
1818
#include <sstream>
1919

20+
#ifdef __linux__
21+
#include <unistd.h>
22+
#endif
23+
2024
#include "ir/hashed.h"
2125
#include "ir/module-utils.h"
2226
#include "pass.h"
@@ -415,7 +419,12 @@ static void dumpWast(Name name, Module* wasm) {
415419
while (numstr.size() < 3) {
416420
numstr = '0' + numstr;
417421
}
418-
auto fullName = std::string("byn-") + numstr + "-" + name.str + ".wasm";
422+
auto fullName = std::string("byn-");
423+
#ifdef __linux__
424+
// TODO: use _getpid() on windows, elsewhere?
425+
fullName += std::to_string(getpid()) + '-';
426+
#endif
427+
fullName += numstr + "-" + name.str + ".wasm";
419428
Colors::disable();
420429
ModuleWriter writer;
421430
writer.setBinary(false); // TODO: add an option for binary

0 commit comments

Comments
 (0)