commit 625c06de6b225f4881581f116a50a50ffd64d672
parent fe3d1feec129390659819f5f99a15cd54e6da281
Author: Jan Klemkow <j.klemkow@wemelug.de>
Date: Mon, 30 Dec 2019 03:10:30 +0100
scroll compiles on OpenBSD
Diffstat:
2 files changed, 28 insertions(+), 10 deletions(-)
diff --git a/Makefile b/Makefile
@@ -0,0 +1,8 @@
+CFLAGS = -std=c99 -pedantic -Wall -Wextra
+LDFLAGS += -lutil
+
+.PHONY: all clean
+
+all: scroll
+clean:
+ rm -f scroll
diff --git a/scroll.c b/scroll.c
@@ -1,18 +1,24 @@
-#define _DEFAULT_SOURCE
-#include <stdio.h>
-#include <termios.h>
+//#define _DEFAULT_SOURCE
+
+#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/select.h>
-#include <stdlib.h>
-#include <pty.h>
-#include <sys/types.h>
-#include <unistd.h>
+#include <sys/wait.h>
+
+#include <assert.h>
+#include <errno.h>
#include <fcntl.h>
+#include <signal.h>
#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
-#include <signal.h>
-#include <sys/wait.h>
-#include <errno.h>
+#include <termios.h>
+#include <unistd.h>
+
+// TODO: OpenBSD/Linux ifdef
+#include <util.h>
+//#include <pty.h>
typedef struct Line Line;
struct Line {
@@ -47,6 +53,8 @@ die(const char *fmt, ...)
void
sigchld(int sig)
{
+ assert(sig == SIGCHLD);
+
pid_t pid;
while ((pid = waitpid(-1, NULL, WNOHANG)) > 0)
if (pid == child)
@@ -56,6 +64,8 @@ sigchld(int sig)
void
sigwinch(int sig)
{
+ assert(sig == SIGWINCH);
+
if (ioctl(1, TIOCGWINSZ, &ws) < 0)
die("ioctl:");
if (ioctl(mfd, TIOCSWINSZ, &ws) < 0)