summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <philip@tecnocode.co.uk>2023-08-16 17:30:59 +0000
committerPhilip Withnall <philip@tecnocode.co.uk>2023-08-16 17:30:59 +0000
commitc91917b1beb59bfac3312d3d882b458bcb90e85a (patch)
treef827f87eee5edc3fd79165a75aead89b93a423c7
parent2838b775580fb1026f7bc5c5da6ae5db456ac5af (diff)
parentde6cebb5f67577ddf438906d7cba7d62fb04631c (diff)
downloadglib-c91917b1beb59bfac3312d3d882b458bcb90e85a.tar.gz
Merge branch 'wip/smcv/o-nonblock' into 'main'
glib-unix: Clean up use of O_NONBLOCK See merge request GNOME/glib!3459
-rw-r--r--glib/glib-unix.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/glib/glib-unix.c b/glib/glib-unix.c
index f671887c9..0532a500c 100644
--- a/glib/glib-unix.c
+++ b/glib/glib-unix.c
@@ -37,6 +37,12 @@ G_STATIC_ASSERT (G_ALIGNOF (gssize) == G_ALIGNOF (ssize_t));
G_STATIC_ASSERT (sizeof (GPid) == sizeof (pid_t));
G_STATIC_ASSERT (G_ALIGNOF (GPid) == G_ALIGNOF (pid_t));
+/* If this assertion fails, then the ABI of g_unix_open_pipe() would be
+ * ambiguous on this platform.
+ * On Linux, usually O_NONBLOCK == 04000 and FD_CLOEXEC == 1, but the same
+ * might not be true everywhere. */
+G_STATIC_ASSERT (O_NONBLOCK != FD_CLOEXEC);
+
/**
* SECTION:gunix
* @title: UNIX-specific utilities and integration
@@ -133,21 +139,9 @@ g_unix_set_fd_nonblocking (gint fd,
return g_unix_set_error_from_errno (error, errno);
if (nonblock)
- {
-#ifdef O_NONBLOCK
- fcntl_flags |= O_NONBLOCK;
-#else
- fcntl_flags |= O_NDELAY;
-#endif
- }
+ fcntl_flags |= O_NONBLOCK;
else
- {
-#ifdef O_NONBLOCK
- fcntl_flags &= ~O_NONBLOCK;
-#else
- fcntl_flags &= ~O_NDELAY;
-#endif
- }
+ fcntl_flags &= ~O_NONBLOCK;
if (fcntl (fd, F_SETFL, fcntl_flags) == -1)
return g_unix_set_error_from_errno (error, errno);