Skip to contentSkip to conversation

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

PATCH In review Khem Raj 4 participants 8 messages Aug 24, 2009 – Aug 26, 2009

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 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

---
 classes/base.bbclass |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
classes/base.bbclass +7 -2
index 598a7bb..4e9b65c 100644
@@ -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)
 
Signature · 1 line
1.6.3.3
#1 lore raw
Quoted 2 lines · On Monday 24 August 2009 04:31:41 Khem Raj wrote:

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

What about giving credit to the guy on irc that:
- Pointed you to the gzip faq
- The launchpad ticket
- The blogpost
- And the above URL?

z.

author
#2 lore raw
Quoted 6 lines · Holger Hans Peter Freyther
Quoted 2 lines · On Monday 24 August 2009 04:31:41 Khem Raj wrote:

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

What about giving credit to the guy on irc that:

indeed. I should edit the git emails before sending them out.

Quoted 4 lines

- Pointed you to the gzip faq
- The launchpad ticket
- The blogpost
- And the above URL?

All of above Zecke's courtesy :) I can put this in git log too before pushing.

Quoted 8 lines

z.

_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel

Acked-by Holger Freyther on v1 1/1
#3 lore raw
In reply to Khem Raj
Quoted 7 lines · On Monday 24 August 2009 04:31:41 Khem Raj wrote:

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.

Quoted 7 lines

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

Quoted 9 lines
---
 classes/base.bbclass |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
classes/base.bbclass +0 -0
index 598a7bb..4e9b65c 100644

classes/base.bbclass base_do_buildall() { · line 735

Quoted 8 lines
classes/base.bbclass +5 -0
@@ -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)

you don't need to import subprocess here...

classes/base.bbclass base_do_buildall() { · line 738

Quoted 4 lines
classes/base.bbclass +1 -1
 def oe_unpack_file(file, data, url = None):
-	import bb, os
+	import bb, os, signal, subprocess

no need for import signal...

Quoted 11 lines
classes/base.bbclass +1 -0
 	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)
#4 lore raw

As a general reminder, please avoid import statements in functions. They're just wasting cycles. Put them into global scope.

:M:

author
#6 lore raw
In reply to Michael 'Mickey' Lauer
Quoted 2 lines · Michael 'Mickey' Lauer

As a general reminder, please avoid import statements in functions. They're just wasting cycles. Put them into global scope.

looking at base.bbclass I decided to leave it as it is to conform to other functions coding style but may be we should move the import to global scope at once sometime.

Thanks

-Khem

Quoted 9 lines

:M:

_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel

#7 lore raw
In reply to Holger Hans Peter Freyther
Quoted 11 lines · Holger Hans Peter Freyther
Quoted 10 lines · On Monday 24 August 2009 04:31:41 Khem Raj wrote:

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.

Quoted 6 lines
Quoted 4 lines

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

Thanks, I've been seeing reports of this and have just merged into Poky! :)

Cheers,

Richard