Fix ttypplot by moving pledge() call after open(/dev/tty).

Add 'use pledge()' marker to Makefile while there.
ok tb@, fcambus@, naddy@
This commit is contained in:
matthieu
2026-04-24 05:59:22 +00:00
parent 1cedb07d17
commit da495d6574
2 changed files with 25 additions and 0 deletions
+2
View File
@@ -3,12 +3,14 @@ COMMENT = realtime plotting utility for terminals
GH_ACCOUNT = tenox7
GH_PROJECT = ttyplot
GH_TAGNAME = 1.7.4
REVISION = 0
CATEGORIES = sysutils
# Apache 2.0
PERMIT_PACKAGE = Yes
# uses pledge()
WANTLIB += c curses m
MAKE_FLAGS = CC="${CC}" CFLAGS="${CFLAGS}"
+23
View File
@@ -12,3 +12,26 @@ Index: ttyplot.c
#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);