summaryrefslogtreecommitdiff
path: root/games/mille/mille.c
diff options
context:
space:
mode:
authorRicardo Mestre <mestre@cvs.openbsd.org>2021-10-23 11:22:50 +0000
committerRicardo Mestre <mestre@cvs.openbsd.org>2021-10-23 11:22:50 +0000
commitecd10c1195d7c68d97eb7d679f932aa85ba050a6 (patch)
tree208ed86a4aec6394b30e888b051761c4aa0e22b5 /games/mille/mille.c
parentd44be2f813bdce978e91422aa39bbc7e6f7466f1 (diff)
if both stdout and stderr are redirected to a non-tty, pledge(2) will kill
ncurses applications, e.g.: /usr/games/worms 2>&1 | cat solve this by only calling pledge(2) after initscr(3) is set and done, or whatever function that calls it. since pledge(2) is called later now the promises might be reduced, but this a diff for another day. found by naddy@ almost a year ago, discussed with him deraadt@ and tb@ ok tb@
Diffstat (limited to 'games/mille/mille.c')
-rw-r--r--games/mille/mille.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/games/mille/mille.c b/games/mille/mille.c
index 5b8684cd9ee..8ab0a082056 100644
--- a/games/mille/mille.c
+++ b/games/mille/mille.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mille.c,v 1.25 2016/01/08 18:09:59 mestre Exp $ */
+/* $OpenBSD: mille.c,v 1.26 2021/10/23 11:22:49 mestre Exp $ */
/* $NetBSD: mille.c,v 1.4 1995/03/24 05:01:48 cgd Exp $ */
/*
@@ -50,9 +50,6 @@ main(int ac, char *av[])
bool restore;
extern char *__progname;
- if (pledge("stdio rpath wpath cpath tty", NULL) == -1)
- err(1, "pledge");
-
#ifdef DEBUG
if (strcmp(av[0], "a.out") == 0) {
outf = fopen("q", "w");
@@ -73,6 +70,10 @@ main(int ac, char *av[])
}
Play = PLAYER;
initscr();
+
+ if (pledge("stdio rpath wpath cpath tty", NULL) == -1)
+ err(1, "pledge");
+
if ((LINES < 24) || (COLS < 80)) {
endwin();
fprintf(stderr, "Screen must be at least 24x80\n");