From 2522deabdaf772900920ad4dcf154f8dc828ad75 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 16 Jan 2023 16:39:37 +0100 Subject: [PATCH] SystemExec: tweak writing to stdin of child process --- libs/pbd/system_exec.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libs/pbd/system_exec.cc b/libs/pbd/system_exec.cc index 2d1b0bc0c5..48f9ea1908 100644 --- a/libs/pbd/system_exec.cc +++ b/libs/pbd/system_exec.cc @@ -936,15 +936,15 @@ SystemExec::write_to_stdin (const void* data, size_t bytes) while (c < bytes) { for (;;) { r = ::write (pin[1], &((const char*)data)[c], bytes - c); - if (r < 0 && (errno == EINTR || errno == EAGAIN)) { - sleep(1); + if (r >= 0) { + break; + } + if (errno == EINTR || errno == EAGAIN) { + g_usleep(100000); continue; } - if ((size_t) r != (bytes-c)) { - ::pthread_mutex_unlock(&write_lock); - return c; - } - break; + ::pthread_mutex_unlock(&write_lock); + return c; } c += r; }