svn commit: r364711 - head/usr.sbin/gstat

Maxim Sobolev sobomax at FreeBSD.org
Mon Aug 24 16:45:24 UTC 2020


Author: sobomax
Date: Mon Aug 24 16:45:23 2020
New Revision: 364711
URL: https://svnweb.freebsd.org/changeset/base/364711

Log:
  In the endless batch mode (-B), terminate if and when stdout is closed.
  That mode is useful to call gstat from other app, however kinda useless
  since gstat won't exit and stay running forever when its parent process
  has long gone.
  
  MFC after:	2 weeks

Modified:
  head/usr.sbin/gstat/gstat.c

Modified: head/usr.sbin/gstat/gstat.c
==============================================================================
--- head/usr.sbin/gstat/gstat.c	Mon Aug 24 16:44:17 2020	(r364710)
+++ head/usr.sbin/gstat/gstat.c	Mon Aug 24 16:45:23 2020	(r364711)
@@ -517,7 +517,8 @@ main(int argc, char **argv)
 			if (!flag_B)
 				loop = 0;
 			else
-				fflush(stdout);
+				if (fflush(stdout) == EOF)
+					goto out;
 			usleep(flag_I);
 			continue;
 		}
@@ -585,7 +586,7 @@ main(int argc, char **argv)
 			}
 		}
 	}
-
+out:
 	if (!flag_b) {
 		el_end(el);
 		endwin();


More information about the svn-src-head mailing list