$OpenBSD: patch-libjack_client_c,v 1.2 2008/06/28 05:49:31 jakemsr Exp $
--- libjack/client.c.orig	Thu May 22 23:20:23 2008
+++ libjack/client.c	Mon Jun 16 20:56:49 2008
@@ -969,10 +969,7 @@ jack_client_open_aux (const char *client_name,
 	}
 
 	/* parse variable arguments */
-	if (ap)
         jack_varargs_parse(options, ap, &va);
-    else
-        jack_varargs_init(&va);
 
 	/* External clients need to know where the tmpdir used for
 	   communication with the server lives
@@ -1114,10 +1111,13 @@ jack_client_t* jack_client_open(const char* ext_client
 jack_client_t *
 jack_client_new (const char *client_name)
 {
+	va_list ap;
+
 	jack_options_t options = JackUseExactName;
 	if (getenv("JACK_START_SERVER") == NULL)
 		options |= JackNoStartServer;
-	return jack_client_open_aux (client_name, options, NULL, NULL);
+
+	return jack_client_open_aux(client_name, options, NULL, ap);
 }
 
 char *
@@ -1519,6 +1519,8 @@ jack_client_core_wait (jack_client_t* client)
 static int
 jack_wake_next_client (jack_client_t* client)
 {
+	struct pollfd pfds[1];
+	int pret = 0;
 	char c = 0;
 
 	if (write (client->graph_next_fd, &c, sizeof (c))
@@ -1530,20 +1532,29 @@ jack_wake_next_client (jack_client_t* client)
 		return -1;
 	}
 	
-	DEBUG ("client sent message to next stage by %" PRIu64
-	       ", client reading on graph_wait_fd==%d", 
-	       jack_get_microseconds(), client->graph_wait_fd);
+	DEBUG ("client sent message to next stage by %" PRIu64 "",
+	       jack_get_microseconds());
 	
 	DEBUG("reading cleanup byte from pipe %d\n", client->graph_wait_fd);
 	
-	if ((read (client->graph_wait_fd, &c, sizeof (c))
-	     != sizeof (c))) {
-		jack_error ("cannot complete execution of the "
-			    "processing graph (%s)",
-			    strerror(errno));
-		return -1;
+	pfds[0].fd = client->graph_wait_fd;
+	pfds[0].events = POLLIN;
+
+	pret = poll(pfds, 1, 0);
+
+	if (pret > 0 && (pfds[0].revents & POLLIN)) {
+		if ((read (client->graph_wait_fd, &c, sizeof (c))
+		     != sizeof (c))) {
+			jack_error ("cannot complete execution of the "
+				    "processing graph (%s)",
+				    strerror(errno));
+			return -1;
+		}
+	} else {
+		DEBUG("cleanup byte from pipe %d not available?\n",
+			client->graph_wait_fd);
 	}
-	
+
 	return 0;
 }
 
