From 332ecb7d294e190400102094d234371e583d9aeb Mon Sep 17 00:00:00 2001 From: pbd Date: Thu, 31 Jul 2003 14:09:11 +0000 Subject: [PATCH] fixes for pipe close issue on RH systems git-svn-id: svn+ssh://jackaudio.org/trunk/jack@440 0c269be4-1314-0410-8aa9-9f06e86f4224 --- configure.in | 5 +++-- jackd/jackd.c | 7 +++++++ jackd/jackstart.c | 18 ++++++++++++++++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/configure.in b/configure.in index dae325e..323770e 100644 --- a/configure.in +++ b/configure.in @@ -13,8 +13,9 @@ dnl micro version = incremented when implementation-only dnl changes are made dnl --- JACK_MAJOR_VERSION=0 -JACK_MINOR_VERSION=74 -JACK_MICRO_VERSION=2 +JACK_MINOR_VERSION=75 +JACK_MICRO_VERSION=0 + dnl --- dnl HOWTO: updating the jack protocal version diff --git a/jackd/jackd.c b/jackd/jackd.c index 91a000e..1f69c5d 100644 --- a/jackd/jackd.c +++ b/jackd/jackd.c @@ -329,6 +329,13 @@ main (int argc, char *argv[]) /* check to see if there is a pipe in the right descriptor */ if ((status = fstat (PIPE_WRITE_FD, &pipe_stat)) == 0 && S_ISFIFO(pipe_stat.st_mode)) { /* tell jackstart we are up and running */ + + char c = 1; + + if (write (PIPE_WRITE_FD, &c, 1) != 1) { + fprintf (stderr, "cannot write to jackstart sync pipe %d (%s)\n", PIPE_WRITE_FD, strerror (errno)); + } + if (close(PIPE_WRITE_FD) != 0) { fprintf(stderr, "jackd: error on startup pipe close: %s\n", strerror (errno)); } else { diff --git a/jackd/jackstart.c b/jackd/jackstart.c index 7b86be3..9a2a56b 100644 --- a/jackd/jackstart.c +++ b/jackd/jackstart.c @@ -203,7 +203,6 @@ int main(int argc, char **argv) gid_t gid; int pipe_fds[2]; int err; - char buf[1]; parent_pid = getpid (); @@ -301,7 +300,22 @@ int main(int argc, char **argv) close(PIPE_WRITE_FD); /* wait for jackd to start */ - while (read(PIPE_READ_FD, buf, sizeof(buf)) == -1 && errno == EINTR) { } + while (1) { + int ret; + char c; + + /* picking up pipe closure is a tricky business. + this seems to work as well as anything else. + */ + + ret = read(PIPE_READ_FD, &c, 1); + fprintf (stderr, "back from read, ret = %d errno == %s\n", ret, strerror (errno)); + if (ret == 1) { + break; + } else if (errno != EINTR) { + break; + } + } /* set privileges on jackd process */ if (give_capabilities (parent_pid) != 0) {