Commit 9b54e1e7 authored by Vincent Hanquez's avatar Vincent Hanquez

don't run anything when the soundplayer command is empty.

use spawn for fork/execve
parent c5da20f1
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment