Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/games/cgram cgram: properly handle input errors
details: https://anonhg.NetBSD.org/src/rev/d61cfeaa888a
branches: trunk
changeset: 959705:d61cfeaa888a
user: rillig <rillig%NetBSD.org@localhost>
date: Mon Feb 22 16:28:20 2021 +0000
description:
cgram: properly handle input errors
On both NetBSD and Cygwin, a missing /usr/bin/fortune would previously
continue since popen does not return an error (as /bin/sh is found and
can be executed), so the next chance to catch an error is pclose. At
that point, the shell has already printed an informative error message
about what happened (or what didn't happen), so that cgram does not need
to print an error by itself.
diffstat:
games/cgram/cgram.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diffs (28 lines):
diff -r f4380145debf -r d61cfeaa888a games/cgram/cgram.c
--- a/games/cgram/cgram.c Mon Feb 22 15:09:50 2021 +0000
+++ b/games/cgram/cgram.c Mon Feb 22 16:28:20 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cgram.c,v 1.11 2021/02/21 22:21:56 rillig Exp $ */
+/* $NetBSD: cgram.c,v 1.12 2021/02/22 16:28:20 rillig Exp $ */
/*-
* Copyright (c) 2013, 2021 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.c,v 1.11 2021/02/21 22:21:56 rillig Exp $");
+__RCSID("$NetBSD: cgram.c,v 1.12 2021/02/22 16:28:20 rillig Exp $");
#endif
#include <assert.h>
@@ -227,7 +227,8 @@
for (int i = 0; i < extent_y; i++)
extent_x = imax(extent_x, (int)lines.v[i].len);
- pclose(f);
+ if (pclose(f) != 0)
+ exit(1); /* error message must come from child process */
}
static void
Home |
Main Index |
Thread Index |
Old Index