svn commit: r282279 - stable/9/usr.bin/wc

Bryan Drewery bdrewery at FreeBSD.org
Thu Apr 30 18:11:44 UTC 2015


Author: bdrewery
Date: Thu Apr 30 18:11:43 2015
New Revision: 282279
URL: https://svnweb.freebsd.org/changeset/base/282279

Log:
  MFC r281617:
  
    wc: Fix SIGINFO race causing final results to be lost to stderr.
  
  Relnotes:	yes

Modified:
  stable/9/usr.bin/wc/wc.c
Directory Properties:
  stable/9/usr.bin/wc/   (props changed)

Modified: stable/9/usr.bin/wc/wc.c
==============================================================================
--- stable/9/usr.bin/wc/wc.c	Thu Apr 30 18:07:48 2015	(r282278)
+++ stable/9/usr.bin/wc/wc.c	Thu Apr 30 18:11:43 2015	(r282279)
@@ -74,6 +74,14 @@ siginfo_handler(int sig __unused)
 	siginfo = 1;
 }
 
+static void
+reset_siginfo(void)
+{
+
+	signal(SIGINFO, SIG_DFL);
+	siginfo = 0;
+}
+
 int
 main(int argc, char *argv[])
 {
@@ -207,6 +215,7 @@ cnt(const char *file)
 					} else
 						tmpll++;
 			}
+			reset_siginfo();
 			tlinect += linect;
 			if (dochar)
 				tcharct += charct;
@@ -229,6 +238,7 @@ cnt(const char *file)
 				return (1);
 			}
 			if (S_ISREG(sb.st_mode)) {
+				reset_siginfo();
 				charct = sb.st_size;
 				show_cnt(file, linect, wordct, charct, llct);
 				tcharct += charct;
@@ -289,6 +299,7 @@ word:	gotsp = 1;
 			}
 		}
 	}
+	reset_siginfo();
 	if (domulti && MB_CUR_MAX > 1)
 		if (mbrtowc(NULL, NULL, 0, &mbs) == (size_t)-1 && !warned)
 			warn("%s", file != NULL ? file : "stdin");


More information about the svn-src-stable-9 mailing list