summaryrefslogtreecommitdiff
path: root/gtk2_ardour/system_exec.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2013-03-28 23:32:02 +0100
committerRobin Gareus <robin@gareus.org>2013-03-28 23:32:02 +0100
commit0c2d95b08f1310533aa14604f7745be8681d10ec (patch)
treea3d717e3813deeeda88c527ba7814e645397478b /gtk2_ardour/system_exec.cc
parentbbb4aa0141d80b6d120d7ab16573fd92007f5f80 (diff)
vtl: fix possible race condition when terminating external program
Diffstat (limited to 'gtk2_ardour/system_exec.cc')
-rw-r--r--gtk2_ardour/system_exec.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/gtk2_ardour/system_exec.cc b/gtk2_ardour/system_exec.cc
index 889b1565ad..44fed48c12 100644
--- a/gtk2_ardour/system_exec.cc
+++ b/gtk2_ardour/system_exec.cc
@@ -409,6 +409,7 @@ SystemExec::make_argp(std::string args) {
void
SystemExec::terminate ()
{
+ ::pthread_mutex_lock(&write_lock);
close_stdin();
if (pid) {
::usleep(100000);
@@ -428,6 +429,8 @@ SystemExec::terminate ()
wait();
if (thread_active) pthread_join(thread_id_tt, NULL);
+ thread_active = false;
+ ::pthread_mutex_unlock(&write_lock);
}
int
@@ -626,6 +629,7 @@ SystemExec::close_stdin()
::close(pin[1]);
::close(pout[0]);
::close(pout[1]);
+ pin[1] = - 1; // mark as closed
}
int