[Pkg-uml-pkgs] Bug#401314: A correction
shaulka at 012.net.il
shaulka at 012.net.il
Sat Dec 2 17:28:00 CET 2006
Due to redirections in the code, the determination of redirected
should be done first.
--- rootstrap.orig 2006-12-02 13:02:06.000000000 +0200
+++ rootstrap.new 2006-12-02 18:16:23.000000000 +0200
@@ -59,12 +59,8 @@
if opt in ('-s', '--image-size'):
imagesize = long(arg)
elif opt in ('-o',):
- if not config.has_option('global', 'debug') or \
- config.get('global', 'debug') != 'true':
- log = open(arg,"w")
- os.dup2(log.fileno(), sys.stdout.fileno())
- else:
- print "Ignoring -o because the debug option is set"
+ log = open(arg,"w")
+ os.dup2(log.fileno(), sys.stdout.fileno())
elif opt in ('-c', '--config'):
umlargs_extra.append('rsconfig=%s' % os.path.abspath(os.path.expanduser(arg)))
elif opt in ('-u', '--umlarg'):
@@ -117,6 +113,27 @@
image.truncate(imagesize * 1048576L)
image.close()
+backgroundRedirection = ''
+if not ( sys.stdin.isatty() and sys.stdout.isatty() and \
+ sys.stderr.isatty() ):
+ backgroundRedirection += 'Redirected'
+if sys.stdin.isatty() and \
+ os.tcgetpgrp(sys.stdin.fileno()) != os.getpgrp():
+ (block_on_read,not_to_be_written_to) = os.pipe()
+ os.dup2(block_on_read,sys.stdin.fileno())
+ backgroundRedirection += 'Background'
+if sys.stdout.isatty() and \
+ os.tcgetpgrp(sys.stdout.fileno()) != os.getpgrp():
+ sink = open('/dev/null','w')
+ os.dup2(sink.fileno(), sys.stdout.fileno())
+ if 'Background' not in backgroundRedirection:
+ backgroundRedirection += 'Background'
+if sys.stderr.isatty() and \
+ os.tcgetpgrp(sys.stderr.fileno()) != os.getpgrp() and \
+ 'Background' not in backgroundRedirection:
+ backgroundRedirection += 'Background'
+umlargs.append('backgroundRedirection=%s' % backgroundRedirection)
+
if os.spawnvpe(os.P_WAIT,umlargs[0], umlargs, os.environ) != 0:
sys.stderr.write("UML exited with non-zero status, aborting\n")
sys.exit(1)
More information about the Pkg-uml-pkgs
mailing list