Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stdout/stderr handling is quirky #2

Open
anarcat opened this issue May 23, 2014 · 1 comment
Open

stdout/stderr handling is quirky #2

anarcat opened this issue May 23, 2014 · 1 comment

Comments

@anarcat
Copy link
Owner

anarcat commented May 23, 2014

the way that bup handles stdout/stderr is a little exotic. it seems to reopen file descriptors under certain circumstances.

this makes it difficult to make subcommands that want to process logging or handle those file descriptors differently. for example, i worked on a wrapper for index/save that redirects stdout to /dev/null (if not verbose) and stderr to a file for logging.

this yields various errors in the logs:

close failed in file object destructor:
sys.excepthook is missing
lost sys.stderr

now this may be a bug in python itself: http://bugs.python.org/issue11380

but it's unclear to me while those file descriptors are being messed with.

@anarcat
Copy link
Owner Author

anarcat commented May 23, 2014

workaround:

diff --git a/main.py b/main.py
index 45a0e8a..e244da5 100755
--- a/main.py
+++ b/main.py
@@ -126,7 +126,7 @@ def subpath(s):
     usage('error: unknown command "%s"' % subcmd_name)

 already_fixed = atoi(os.environ.get('BUP_FORCE_TTY'))
-if subcmd_name in ['mux', 'ftp', 'help']:
+if subcmd_name in ['mux', 'ftp', 'help', 'cron']:
     already_fixed = True
 fix_stdout = not already_fixed and os.isatty(1)
 fix_stderr = not already_fixed and os.isatty(2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant