Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Aug 2020 16:45:24 +0000 (UTC)
From:      Maxim Sobolev <sobomax@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r364711 - head/usr.sbin/gstat
Message-ID:  <202008241645.07OGjOYC086962@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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();



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008241645.07OGjOYC086962>