Module Name:    src
Committed By:   gutteridge
Date:           Tue May 17 00:21:22 UTC 2022

Modified Files:
        src/usr.sbin/makemandb: apropos.c

Log Message:
apropos.c: fix pager functionality

Issue reported by Rocky Hotas on NetBSD-Users, patch input from RVP on
same, adjustments by me.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.sbin/makemandb/apropos.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makemandb/apropos.c
diff -u src/usr.sbin/makemandb/apropos.c:1.24 src/usr.sbin/makemandb/apropos.c:1.25
--- src/usr.sbin/makemandb/apropos.c:1.24	Sat Nov 25 14:29:38 2017
+++ src/usr.sbin/makemandb/apropos.c	Tue May 17 00:21:22 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos.c,v 1.24 2017/11/25 14:29:38 abhinav Exp $	*/
+/*	$NetBSD: apropos.c,v 1.25 2022/05/17 00:21:22 gutteridge Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadh...@gmail.com>
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: apropos.c,v 1.24 2017/11/25 14:29:38 abhinav Exp $");
+__RCSID("$NetBSD: apropos.c,v 1.25 2022/05/17 00:21:22 gutteridge Exp $");
 
 #include <err.h>
 #include <stdio.h>
@@ -157,6 +157,7 @@ main(int argc, char *argv[])
 	char *query = NULL;	// the user query
 	char *errmsg = NULL;
 	char *str;
+	int pc = 0;
 	int rc = 0;
 	size_t i;
 	int s;
@@ -249,6 +250,8 @@ main(int argc, char *argv[])
 	if (aflags.format == APROPOS_HTML)
 		fprintf(cbdata.out, "</table>\n</body>\n</html>\n");
 
+	if (aflags.pager)
+		pc = pclose(cbdata.out);
 	free(query);
 
 	if (aflags.sections) {
@@ -264,6 +267,9 @@ main(int argc, char *argv[])
 		exit(EXIT_FAILURE);
 	}
 
+	if (pc == -1)
+		err(EXIT_FAILURE, "pclose error");
+
 	if (rc < 0) {
 		/* Something wrong with the database. Exit */
 		exit(EXIT_FAILURE);

Reply via email to