[oe-commits] Khem Raj : base.bbclass: Replace os.system with subprocess call.

git version control git at git.openembedded.org
Wed Aug 26 07:39:28 UTC 2009


Module: openembedded.git
Branch: org.openembedded.dev
Commit: f73c64e7295be1e1065f898b49f50a02e812161c
URL:    http://gitweb.openembedded.net/?p=openembedded.git&a=commit;h=f73c64e7295be1e1065f898b49f50a02e812161c

Author: Khem Raj <raj.khem at gmail.com>
Date:   Sun Aug 23 19:24:57 2009 -0700

base.bbclass: Replace os.system with subprocess call.

Often gzip is reporting broken pipe errors with do_unpack of
tar.gz files.

If you use the commands described above to extract a tar.gz file, gzip
sometimes emits a Broken pipe error message. This can safely be ignored
if tar extracted all files without any other error message.

We do not let python install its SIGPIPE handler and use subprocess call
to invoke the command.

This is based on the following python bug report.
http://bugs.python.org/issue1652

Signed-off-by: Khem Raj <raj.khem at gmail.com>

---

 classes/base.bbclass |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/classes/base.bbclass b/classes/base.bbclass
index 598a7bb..4e9b65c 100644
--- a/classes/base.bbclass
+++ b/classes/base.bbclass
@@ -728,9 +728,14 @@ base_do_buildall() {
 	:
 }
 
+def subprocess_setup():
+	import signal, subprocess
+	# Python installs a SIGPIPE handler by default. This is usually not what
+	# non-Python subprocesses expect.
+	signal.signal(signal.SIGPIPE, signal.SIG_DFL)
 
 def oe_unpack_file(file, data, url = None):
-	import bb, os
+	import bb, os, signal, subprocess
 	if not url:
 		url = "file://%s" % file
 	dots = file.split(".")
@@ -799,7 +804,7 @@ def oe_unpack_file(file, data, url = None):
 
 	cmd = "PATH=\"%s\" %s" % (bb.data.getVar('PATH', data, 1), cmd)
 	bb.note("Unpacking %s to %s/" % (base_path_out(file, data), base_path_out(os.getcwd(), data)))
-	ret = os.system(cmd)
+	ret = subprocess.call(cmd, preexec_fn=subprocess_setup, shell=True)
 
 	os.chdir(save_cwd)
 





More information about the Openembedded-commits mailing list