commit b86cb86b33cd3aa8794ef66d73a0bcba11f093fb
parent dc70dd00cb8694cb50950c91a7d5fe61e5005285
Author: Antoni Sawicki <tenox@google.com>
Date: Fri, 10 May 2019 01:29:57 -0700
Merge pull request #37 from sjmulder/pr/pledge
Add pledge() support
Diffstat:
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/ttyplot.c b/ttyplot.c
@@ -14,6 +14,10 @@
#include <curses.h>
#include <signal.h>
+#ifdef __OpenBSD__
+#include <err.h>
+#endif
+
#define verstring "github.com/tenox7/ttyplot 1.4"
#ifdef NOACS
@@ -179,8 +183,14 @@ int main(int argc, char *argv[]) {
break;
}
+ initscr(); /* uses filesystem, so before pledge */
+
+#ifdef __OpenBSD__
+ if (pledge("stdio tty", NULL) == -1)
+ err(1, "pledge");
+#endif
+
time(&t1);
- initscr();
noecho();
curs_set(FALSE);
signal(SIGWINCH, (void*)resize);