commit b3ead0f7985d0e8ae925851fe1b75be8779f7c33
Author: Radek Novacek <rnovacek(a)redhat.com>
Date: Mon Sep 5 09:57:02 2011 +0200
Fork when running on the background
virt-who.py | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/virt-who.py b/virt-who.py
index e10f6c0..949fa6c 100644
--- a/virt-who.py
+++ b/virt-who.py
@@ -60,6 +60,16 @@ if __name__ == '__main__':
logger.addHandler(logging.StreamHandler())
if options.background:
+ try:
+ pid = os.fork()
+ except OSError:
+ logger.error("Unable to fork, continuing in foreground")
+ pid = 0
+
+ if pid > 0:
+ # Parent process
+ sys.exit(0)
+
virEventLoopPureStart()
try:
Show replies by date