From 23b18b377ea77f2ea783070cb33df748fcc023a9 Mon Sep 17 00:00:00 2001 From: "ziemowit.leszczynski" Date: Wed, 21 Aug 2024 12:46:35 +0200 Subject: [PATCH] unix: fix socket flags Sockets can read and write by default. Required for fdopen() to work on unix sockets. F_SETFL returns 0 on success. JIRA: RTOS-892 --- posix/unix.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/posix/unix.c b/posix/unix.c index 5e19ac366..685ae3705 100644 --- a/posix/unix.c +++ b/posix/unix.c @@ -947,7 +947,7 @@ int unix_setfl(unsigned socket, int flags) s->nonblock = (flags & O_NONBLOCK) != 0; unixsock_put(s); - return flags; + return 0; } @@ -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;