diff options
author | Lars Wirzenius <liw@liw.fi> | 2012-10-09 15:50:07 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2012-10-09 15:50:07 +0100 |
commit | 9fd44074ec8b6ac4aee6c153029a06ec46cc903a (patch) | |
tree | 47819cbb72f8fd7bead2d25c92a59ac95494f758 /cliapp/app.py | |
parent | 6ac3a4976d33da039fb3abcb6a85bd335a1c060c (diff) | |
download | cliapp-9fd44074ec8b6ac4aee6c153029a06ec46cc903a.tar.gz |
Handle process name setting IOErrors gracefully
Diffstat (limited to 'cliapp/app.py')
-rw-r--r-- | cliapp/app.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/cliapp/app.py b/cliapp/app.py index e7d880b..453b393 100644 --- a/cliapp/app.py +++ b/cliapp/app.py @@ -142,10 +142,13 @@ class Application(object): return ''.join(x.upper() if x in ok else '_' for x in basename) - def _set_process_name(self): + def _set_process_name(self): # pragma: no cover if platform.system() == 'Linux': - with open("/proc/%d/comm" % (os.getpid()), "wb", 0) as fh: - fh.write(self.settings.progname[:15]) + try: + with open('/proc/self/comm', 'w', 0) as f: + f.write(self.settings.progname[:15]) + except IOError, e: + logging.warning(str(e)) def _run(self, args=None, stderr=sys.stderr, log=logging.critical): try: |