waf: configure option for enforcing autostart method
[jackdbus.git] / linux / alsarawmidi / JackALSARawMidiUtil.cpp
blobc71d7b2b0fa731782125bd03ab2cb87ddca7e349
1 #include <cerrno>
2 #include <cstring>
3 #include <stdexcept>
5 #include <fcntl.h>
6 #include <unistd.h>
8 #include "JackALSARawMidiUtil.h"
10 void
11 Jack::CreateNonBlockingPipe(int *fds)
13 if (pipe(fds) == -1) {
14 throw std::runtime_error(strerror(errno));
16 try {
17 SetNonBlocking(fds[0]);
18 SetNonBlocking(fds[1]);
19 } catch (...) {
20 close(fds[1]);
21 close(fds[0]);
22 throw;
26 void
27 Jack::DestroyNonBlockingPipe(int *fds)
29 close(fds[1]);
30 close(fds[0]);
33 void
34 Jack::SetNonBlocking(int fd)
36 int flags = fcntl(fd, F_GETFL);
37 if (flags == -1) {
38 throw std::runtime_error(strerror(errno));
40 if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1) {
41 throw std::runtime_error(strerror(errno));