From 60f945fd1bc6b8d4ef561d1eb17c327ecc3c954b Mon Sep 17 00:00:00 2001
From: Dirk Loss <mail@dirk-loss.de>
Date: Wed, 9 Dec 2009 21:23:29 +0100
Subject: [PATCH] Use subprocess instead of os.system to launch PDF/PS viewer

os.system() is deprecated, does not work correctly if the
path name of the executable includes spaces, and needs an
ampersand to put the called program in the background
(which does not work on Windows).
subprocess.Popen() solves all these problems.
---
 scapy/packet.py | 4 ++--
 scapy/plist.py  | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/scapy/packet.py b/scapy/packet.py
index 641cf4f4..4e3c893c 100644
--- a/scapy/packet.py
+++ b/scapy/packet.py
@@ -354,7 +354,7 @@ Creates an EPS file describing a packet. If filename is not provided a temporary
         if filename is None:
             fname = get_temp_file(autoext=".eps")
             canvas.writeEPSfile(fname)
-            os.system("%s '%s.eps' &" % (conf.prog.psreader,fname))
+            subprocess.Popen([conf.prog.psreader, fname+".eps"])
         else:
             canvas.writeEPSfile(filename)
 
@@ -365,7 +365,7 @@ Creates an EPS file describing a packet. If filename is not provided a temporary
         if filename is None:
             fname = get_temp_file(autoext=".pdf")
             canvas.writePDFfile(fname)
-            os.system("%s '%s.pdf' &" % (conf.prog.pdfreader,fname))
+            subprocess.Popen([conf.prog.pdfreader, fname+".pdf"])
         else:
             canvas.writePDFfile(filename)
 
diff --git a/scapy/plist.py b/scapy/plist.py
index 716727a0..4cb01a7a 100644
--- a/scapy/plist.py
+++ b/scapy/plist.py
@@ -3,7 +3,7 @@
 ## Copyright (C) Philippe Biondi <phil@secdev.org>
 ## This program is published under a GPLv2 license
 
-import os
+import os,subprocess
 from config import conf
 from base_classes import BasePacket,BasePacketList
 from packet import Padding
@@ -363,7 +363,7 @@ lfilter: truth function to apply to each packet to decide whether it will be dis
         if filename is None:
             filename = get_temp_file(autoext=".ps")
             d.writePSfile(filename)
-            os.system("%s %s.ps &" % (conf.prog.psreader,filename))
+            subprocess.Popen([conf.prog.psreader, filename+".ps"])
         else:
             d.writePSfile(filename)
         print
@@ -376,7 +376,7 @@ lfilter: truth function to apply to each packet to decide whether it will be dis
         if filename is None:
             filename = get_temp_file(autoext=".pdf")
             d.writePDFfile(filename)
-            os.system("%s %s.pdf &" % (conf.prog.pdfreader,filename))
+            subprocess.Popen([conf.prog.pdfreader, filename+".pdf"])
         else:
             d.writePDFfile(filename)
         print
-- 
GitLab