fix: keep FIFO fd open across both writes to prevent hang

Co-authored-by: aider (deepseek/deepseek-reasoner) <aider@aider.chat>
This commit is contained in:
Loic Coenen
2026-05-10 00:16:03 +00:00
parent c592c24634
commit be3188bbe2

View File

@@ -860,8 +860,7 @@ static int test_fifo_pipe(void) {
return 1; return 1;
} }
write(fd, "add\n", 4); write(fd, "add\n", 4);
close(fd); /* Keep fd open; do NOT close yet */
safe_usleep(1500000); /* give main loop time to process */ safe_usleep(1500000); /* give main loop time to process */
const char **ports = jack_get_ports(client, NULL, JACK_DEFAULT_AUDIO_TYPE, 0); const char **ports = jack_get_ports(client, NULL, JACK_DEFAULT_AUDIO_TYPE, 0);
@@ -876,14 +875,7 @@ static int test_fifo_pipe(void) {
jack_free(ports); jack_free(ports);
} }
/* Write "remove\n" to the FIFO */ /* Write "remove\n" to the FIFO, same fd */
fd = open("/tmp/looper_cmd", O_WRONLY);
if (fd < 0) {
perror("open fifo");
jack_client_close(client);
kill(pid, SIGTERM); waitpid(pid, NULL, 0);
return 1;
}
write(fd, "remove\n", 7); write(fd, "remove\n", 7);
close(fd); close(fd);