don't run anything when the soundplayer command is empty.
use spawn for fork/execve
This commit is contained in:
parent
c5da20f12a
commit
9b54e1e7c9
|
@ -266,23 +266,18 @@ class plugin:
|
||||||
|
|
||||||
|
|
||||||
def play_sound(self, event):
|
def play_sound(self, event):
|
||||||
if not os.name == 'posix':
|
if os.name != 'posix':
|
||||||
|
return
|
||||||
|
if self.config['soundplayer'] == '':
|
||||||
return
|
return
|
||||||
if not self.config[event]:
|
if not self.config[event]:
|
||||||
return
|
return
|
||||||
file = self.config[event + '_file']
|
file = self.config[event + '_file']
|
||||||
if not os.path.exists(file):
|
if not os.path.exists(file):
|
||||||
return
|
return
|
||||||
pid = os.fork()
|
|
||||||
if pid == 0:
|
|
||||||
argv = self.config['soundplayer'].split()
|
argv = self.config['soundplayer'].split()
|
||||||
argv.append(file)
|
argv.append(file)
|
||||||
try:
|
pid = os.spawnvp(os.P_NOWAIT, argv[0], argv)
|
||||||
os.execvp(argv[0], argv)
|
|
||||||
except:
|
|
||||||
print _("error while running %s :") % ' '.join(argv), \
|
|
||||||
sys.exc_info()[1]
|
|
||||||
os._exit(1)
|
|
||||||
pidp, r = os.waitpid(pid, os.WNOHANG)
|
pidp, r = os.waitpid(pid, os.WNOHANG)
|
||||||
if pidp == 0:
|
if pidp == 0:
|
||||||
gobject.timeout_add(10000, self.play_timeout, pid)
|
gobject.timeout_add(10000, self.play_timeout, pid)
|
||||||
|
|
Loading…
Reference in New Issue