pkgsrc/audio/pulseaudio/patches/patch-da

45 lines
1.6 KiB
Text

$NetBSD: patch-da,v 1.1 2010/02/01 15:00:20 jmcneill Exp $
--- src/modules/module-cli.c.orig 2009-11-23 03:57:05.000000000 +0000
+++ src/modules/module-cli.c
@@ -105,6 +105,32 @@ int pa__init(pa_module*m) {
* of log messages, particularly because if stdout and stderr are
* dup'ed they share the same O_NDELAY, too. */
+#ifndef O_CLOEXEC
+ if ((fd = open("/dev/tty", O_RDWR|O_NONBLOCK)) >= 0) {
+ int flags;
+ if ((flags = fcntl(fd, F_GETFD)) < 0) {
+ pa_log_debug("Couldn't get file handle flags");
+ close(fd);
+ fd = -1;
+ goto error;
+ }
+ flags |= FD_CLOEXEC;
+ if (fcntl(fd, F_SETFD, flags) < 0) {
+ pa_log_debug("Couldn't set file handle flags");
+ close(fd);
+ fd = -1;
+ goto error;
+ }
+ io = pa_iochannel_new(m->core->mainloop, fd, fd);
+ pa_log_debug("Managed to open /dev/tty.");
+ }
+error:
+ if (fd < 0) {
+ io = pa_iochannel_new(m->core->mainloop, STDIN_FILENO, STDOUT_FILENO);
+ pa_iochannel_set_noclose(io, TRUE);
+ pa_log_debug("Failed to open /dev/tty, using stdin/stdout fds instead.");
+ }
+#else
if ((fd = open("/dev/tty", O_RDWR|O_CLOEXEC|O_NONBLOCK)) >= 0) {
io = pa_iochannel_new(m->core->mainloop, fd, fd);
pa_log_debug("Managed to open /dev/tty.");
@@ -113,6 +139,7 @@ int pa__init(pa_module*m) {
pa_iochannel_set_noclose(io, TRUE);
pa_log_debug("Failed to open /dev/tty, using stdin/stdout fds instead.");
}
+#endif
m->userdata = pa_cli_new(m->core, io, m);
pa_cli_set_eof_callback(m->userdata, exit_on_eof ? eof_and_exit_cb : eof_and_unload_cb, m);