Improve execv to prevent crash if command is wrong
This commit is contained in:
1 parent
038c87b14a
commit
ae0123eaaa
1 file changed
+8
-2
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user