Minor patch (flushing log file output at the end of program run)

This commit is contained in:
Miroslav Stampar 2014-10-10 10:07:17 +02:00
parent 7811a958ae
commit d4610890ca
2 changed files with 10 additions and 0 deletions

View File

@ -73,6 +73,13 @@ class Dump(object):
kb.dataOutputFlag = True kb.dataOutputFlag = True
def flush(self):
if self._outputFP:
try:
self._outputFP.flush()
except IOError:
pass
def setOutputFile(self): def setOutputFile(self):
self._outputFile = os.path.join(conf.outputPath, "log") self._outputFile = os.path.join(conf.outputPath, "log")
try: try:

View File

@ -156,6 +156,9 @@ def main():
except KeyboardInterrupt: except KeyboardInterrupt:
pass pass
if conf.get("dumper"):
conf.dumper.flush()
# Reference: http://stackoverflow.com/questions/1635080/terminate-a-multi-thread-python-program # Reference: http://stackoverflow.com/questions/1635080/terminate-a-multi-thread-python-program
if conf.get("threads", 0) > 1 or conf.get("dnsServer"): if conf.get("threads", 0) > 1 or conf.get("dnsServer"):
os._exit(0) os._exit(0)