From 9b54e1e7c9a4e5773d3a30e84dd95ffeafcaddc3 Mon Sep 17 00:00:00 2001 From: Vincent Hanquez Date: Mon, 14 Mar 2005 18:59:27 +0000 Subject: [PATCH] don't run anything when the soundplayer command is empty. use spawn for fork/execve --- plugins/gtkgui/gtkgui.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/plugins/gtkgui/gtkgui.py b/plugins/gtkgui/gtkgui.py index cc24c2595..8e2df4f43 100644 --- a/plugins/gtkgui/gtkgui.py +++ b/plugins/gtkgui/gtkgui.py @@ -266,23 +266,18 @@ class plugin: def play_sound(self, event): - if not os.name == 'posix': + if os.name != 'posix': + return + if self.config['soundplayer'] == '': return if not self.config[event]: return file = self.config[event + '_file'] if not os.path.exists(file): return - pid = os.fork() - if pid == 0: - argv = self.config['soundplayer'].split() - argv.append(file) - try: - os.execvp(argv[0], argv) - except: - print _("error while running %s :") % ' '.join(argv), \ - sys.exc_info()[1] - os._exit(1) + argv = self.config['soundplayer'].split() + argv.append(file) + pid = os.spawnvp(os.P_NOWAIT, argv[0], argv) pidp, r = os.waitpid(pid, os.WNOHANG) if pidp == 0: gobject.timeout_add(10000, self.play_timeout, pid)