Files
matthieu da495d6574 Fix ttypplot by moving pledge() call after open(/dev/tty).
Add 'use pledge()' marker to Makefile while there.
ok tb@, fcambus@, naddy@
2026-04-24 05:59:22 +00:00

38 lines
1016 B
Plaintext

OpenBSD also needs the _XOPEN_SOURCE_EXTENDED define.
Index: ttyplot.c
--- ttyplot.c.orig
+++ ttyplot.c
@@ -8,7 +8,7 @@
// This is needed on FreeBSD and macOS to get the ncurses widechar API,
// and pkg-config fails to define it.
-#if defined(__APPLE__) || defined(__FreeBSD__)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#define _XOPEN_SOURCE_EXTENDED
#else
// This is needed for musl libc
@@ -923,10 +923,6 @@ int main(int argc, char *argv[]) {
exit(1);
}
-#ifdef __OpenBSD__
- if (pledge("stdio tty", NULL) == -1)
- err(1, "pledge");
-#endif
// Check if any colors are defined
bool has_colors = false;
@@ -986,6 +982,11 @@ int main(int argc, char *argv[]) {
signal(SIGWINCH, signal_handler);
signal(SIGINT, signal_handler);
+
+#ifdef __OpenBSD__
+ if (pledge("stdio tty", NULL) == -1)
+ err(1, "pledge");
+#endif
while (1) {
struct timeval timeout = calculate_clock_refresh_timeout_from(now.tv_usec);