From 71f97e742d37a0330fb2182aba1b5017cd11cab3 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Mon, 21 Nov 2005 05:36:29 +0000 Subject: [PATCH] Workaround for failure to create command batch files. Thanks to Bronek Kozicki. [SVN r31718] --- src/engine/execnt.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/engine/execnt.c b/src/engine/execnt.c index 9b62c169b..29a6b6515 100644 --- a/src/engine/execnt.c +++ b/src/engine/execnt.c @@ -577,11 +577,20 @@ execcmd( } else { - FILE *f; + FILE *f = 0; + int tries = 0; raw_cmd = 0; - /* Write command to bat file. */ - f = fopen( cmdtab[ slot ].tempfile, "w" ); + /* Write command to bat file. For some reason this open can + fails intermitently. But doing some retries works. Most likely + this is due to a previously existing file of the same name that + happens to be opened by an active virus scanner. Pointed out, + and fix by Bronek Kozicki. */ + for (; !f && tries < 4; ++tries) + { + f = fopen( cmdtab[ slot ].tempfile, "w" ); + if ( !f && tries < 4 ) Sleep( 250 ); + } if (!f) { printf( "failed to write command file!\n" );