Skip to content

Commit

Permalink
Merge branch 'cloexec'
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Williams committed May 7, 2015
2 parents 938a6d3 + 876cd1e commit 540f6cf
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/serialport_unix.cpp
Expand Up @@ -174,15 +174,22 @@ int setup(int fd, OpenBaton *data) {


int flags = (O_RDWR | O_NOCTTY | O_NONBLOCK | O_CLOEXEC | O_SYNC);
if(data->hupcl == false)
flags &= ~HUPCL;
if(data->hupcl == false) {
flags &= ~HUPCL;
}
int fd = open(data->path, flags);

if (fd == -1) {
snprintf(data->errorString, sizeof(data->errorString), "Cannot open %s", data->path);
return -1;
}

//Snow Leopard doesn't have O_CLOEXEC
int cloexec = fcntl(fd, F_SETFD, FD_CLOEXEC);
if (cloexec == -1) {
snprintf(data->errorString, sizeof(data->errorString), "Cannot open %s", data->path);
return;
}

// struct sigaction saio;
// saio.sa_handler = sigio_handler;
Expand Down

0 comments on commit 540f6cf

Please sign in to comment.