Skip to content

Commit

Permalink
unix: fix socket flags
Browse files Browse the repository at this point in the history
Sockets can read and write by default. Required for fdopen() to work on unix sockets.
F_SETFL returns 0 on success.

JIRA: RTOS-892
  • Loading branch information
ziemleszcz committed Aug 22, 2024
1 parent fa2cb46 commit 23b18b3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions posix/unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ int unix_setfl(unsigned socket, int flags)
s->nonblock = (flags & O_NONBLOCK) != 0;

unixsock_put(s);
return flags;
return 0;
}


Expand All @@ -959,7 +959,10 @@ int unix_getfl(unsigned socket)
if ((s = unixsock_get(socket)) == NULL)
return -ENOTSOCK;

flags = s->nonblock ? O_NONBLOCK : 0;
flags = O_RDWR;
if (s->nonblock) {
flags |= O_NONBLOCK;
}

unixsock_put(s);
return flags;
Expand Down

0 comments on commit 23b18b3

Please sign in to comment.