[libbsd 8/9] netstat: Do not use signals

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Jun 10 06:08:34 UTC 2022


---
 freebsd/usr.bin/netstat/if.c                  | 19 ++++---------------
 .../netstat/rtems-bsd-netstat-if-data.h       |  2 --
 2 files changed, 4 insertions(+), 17 deletions(-)

diff --git a/freebsd/usr.bin/netstat/if.c b/freebsd/usr.bin/netstat/if.c
index c578629e..ffb639c6 100644
--- a/freebsd/usr.bin/netstat/if.c
+++ b/freebsd/usr.bin/netstat/if.c
@@ -512,6 +512,7 @@ intpr(void (*pfunc)(char *), int af)
 		freeifmaddrs(ifmap);
 }
 
+#ifndef __rtems__
 struct iftot {
 	u_long	ift_ip;			/* input packets */
 	u_long	ift_ie;			/* input errors */
@@ -575,6 +576,7 @@ catchalarm(int signo __unused)
 {
 	signalled = true;
 }
+#endif /* __rtems__ */
 
 /*
  * Print a running summary of interface statistics.
@@ -585,6 +587,7 @@ catchalarm(int signo __unused)
 static void
 sidewaysintpr(void)
 {
+#ifndef __rtems__
 	struct iftot ift[2], *new, *old;
 	struct itimerval interval_it;
 	int oldmask, line;
@@ -619,26 +622,11 @@ loop:
 		xo_close_list("interface-statistics");
 		return;
 	}
-#ifdef __rtems__
-	{
-	sigset_t oldmask, desired, empty;
-
-	sigemptyset(&empty);
-	sigemptyset(&desired);
-	sigaddset(&desired, SIGALRM);
-	sigprocmask(SIG_BLOCK, &desired, &oldmask);
-	while (!signalled)
-		sigsuspend(&desired);
-	signalled = false;
-	sigprocmask(SIG_SETMASK, &oldmask, NULL);
-	}
-#else /* __rtems__ */
 	oldmask = sigblock(sigmask(SIGALRM));
 	while (!signalled)
 		sigpause(0);
 	signalled = false;
 	sigsetmask(oldmask);
-#endif /* __rtems__ */
 	line++;
 
 	fill_iftot(new);
@@ -681,4 +669,5 @@ loop:
 		goto loop;
 
 	/* NOTREACHED */
+#endif /* __rtems__ */
 }
diff --git a/freebsd/usr.bin/netstat/rtems-bsd-netstat-if-data.h b/freebsd/usr.bin/netstat/rtems-bsd-netstat-if-data.h
index 9e12b65e..9a685f33 100644
--- a/freebsd/usr.bin/netstat/rtems-bsd-netstat-if-data.h
+++ b/freebsd/usr.bin/netstat/rtems-bsd-netstat-if-data.h
@@ -1,5 +1,3 @@
 /* generated by userspace-header-gen.py */
 #include <rtems/linkersets.h>
 #include "rtems-bsd-netstat-data.h"
-/* if.c */
-RTEMS_LINKER_RWSET_CONTENT(bsd_prog_netstat, static sig_atomic_t signalled);
-- 
2.35.3



More information about the devel mailing list