[binutils-gdb] Use F_SETFL after F_SETOWN

Tom Tromey via Gdb-cvs <[email protected]>
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3698409f0bc413c7e1452ec6b5867f25eb96451c

commit 3698409f0bc413c7e1452ec6b5867f25eb96451c
Author: Tom Tromey <[email protected]>
Date:   Wed Jul 1 12:48:49 2026 -0600

    Use F_SETFL after F_SETOWN
    
    This changes enable_async_notification to use F_SETFL after F_SETOWN.
    This order more correct because it ensures that the owning process is
    set before the request to enable SIGIO.
    
    Approved-By: Simon Marchi <[email protected]>

Diff:
---
 gdbserver/remote-utils.cc | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/gdbserver/remote-utils.cc b/gdbserver/remote-utils.cc
index ffde4956776..ff71eb67482 100644
--- a/gdbserver/remote-utils.cc
+++ b/gdbserver/remote-utils.cc
@@ -128,13 +128,11 @@ static void
 enable_async_notification (int fd)
 {
 #if defined(F_SETFL) && defined (FASYNC)
-  int save_fcntl_flags;
-
-  save_fcntl_flags = fcntl (fd, F_GETFL, 0);
-  fcntl (fd, F_SETFL, save_fcntl_flags | FASYNC);
-#if defined (F_SETOWN)
+#  if defined (F_SETOWN)
   fcntl (fd, F_SETOWN, getpid ());
-#endif
+#  endif
+  int save_fcntl_flags = fcntl (fd, F_GETFL, 0);
+  fcntl (fd, F_SETFL, save_fcntl_flags | FASYNC);
 #endif
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.