]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use F_SETFL after F_SETOWN
authorTom Tromey <tromey@adacore.com>
Wed, 1 Jul 2026 18:48:49 +0000 (12:48 -0600)
committerTom Tromey <tromey@adacore.com>
Wed, 12 Aug 2026 19:18:05 +0000 (13:18 -0600)
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 <simon.marchi@efficios.com>
gdbserver/remote-utils.cc

index ffde495677631fe87bcabca8ca9f5c31af5b76bc..ff71eb6748296414cf342dafb672172a0fb45535 100644 (file)
@@ -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
 }