Skip to contentSkip to conversation

vl: avoid closing stdout with 'writeconfig'

PATCH Applied Chen Gang 2 participants 2 messages Apr 22, 2014 – Apr 25, 2014

lore
Share & tools
lore

Chen Gang

author
#0 lore raw

PATCH v2 1/1 vl: avoid closing stdout with 'writeconfig'

'writeconfig' supports output to stdout (with '-'); when that happens, we must not close stdout, or further command line options that also use stdout will be impacted. (Although 'writeconfig' was copied from 'readconfig', the latter does not have the problem because it does not support reading from '-')

---
 vl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
vl.c +3 -1
index 9975e5a..215467f 100644
@@ -3855,7 +3855,9 @@ int main(int argc, char **argv, char **envp)
                         }
                     }
                     qemu_config_write(fp);
-                    fclose(fp);
+                    if (fp != stdout) {
+                        fclose(fp);
+                    }
                     break;
                 }
             case QEMU_OPTION_qtest:
Signature · 1 line
1.7.11.7
#1 lore raw

22.04.2014 05:12, Chen Gang wrotr:

Quoted 5 lines

'writeconfig' supports output to stdout (with '-'); when that happens, we must not close stdout, or further command line options that also use stdout will be impacted. (Although 'writeconfig' was copied from 'readconfig', the latter does not have the problem because it does not support reading from '-')

Thanks, applied to -trivial.

/mjt