From ae0123eaaa442dc157239978a3d6796eb2771618 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 4 Nov 2008 15:27:42 +0100 Subject: [PATCH] Improve execv to prevent crash if command is wrong --- tryton/common/common.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tryton/common/common.py b/tryton/common/common.py index 66afd452b0..f0aa445ae9 100644 --- a/tryton/common/common.py +++ b/tryton/common/common.py @@ -272,7 +272,10 @@ def file_open(filename, type, parent, print_p=False): if not pid: pid = os.fork() if not pid: - os.execv('/usr/bin/open', ['/usr/bin/open', filename]) + try: + os.execv('/usr/bin/open', ['/usr/bin/open', filename]) + except: + sys.exit(0) time.sleep(0.1) sys.exit(0) os.waitpid(pid, 0) @@ -308,7 +311,10 @@ def file_open(filename, type, parent, print_p=False): if not pid: prog, args = cmd.split(' ', 1) args = [os.path.basename(prog)] + args.split(' ') - os.execv(prog, args) + try: + os.execv(prog, args) + except: + sys.exit(0) time.sleep(0.1) sys.exit(0) os.waitpid(pid, 0)