winegcc: wait when temp file already exists

In some obscure cases a file get built twice (with equal environment
and arguments) so that temp file exists in a parallel build. The
solution to this is to wait some time (12 * 5sec), hoping that the other
process is done and release the filename.

Signed-off-by: Marko Semet <marko@marko10-000.de>
feature/deterministic
Marko Semet 2020-06-21 03:10:43 +02:00
parent cb6fcfc2bb
commit 1b87584bf5
1 changed files with 13 additions and 1 deletions

View File

@ -428,7 +428,19 @@ int pseudorandom_tempfile(char* file)
}
/* try to open file */
return open(file, O_CREAT | O_EXCL | O_RDWR, 0600);
int result;
int counter = 0;
do
{
result = open(file, O_CREAT | O_EXCL | O_RDWR, 0600);
if (result != -1)
{
break;
}
sleep(5);
counter++;
} while (counter <= 12);
return result;
}
void init_random_generator(int argc, char **argv)