summaryrefslogtreecommitdiff
path: root/st/patches/st-externalpipe-signal-0.8.2.diff
blob: c573d514d1cdd8f99455a589f99db6e27e56207b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
From df32a82e8a889629ed406ce468f24c35da7e9a03 Mon Sep 17 00:00:00 2001
From: Miles Alan <m@milesalan.com>
Date: Sun, 11 Aug 2019 21:33:55 -0500
Subject: [PATCH] Add handler for SIGUSR1 signal to run an externalpipe command

---
 config.def.h |  1 +
 st.c         | 14 ++++++++++++++
 st.h         |  1 +
 3 files changed, 16 insertions(+)

diff --git a/config.def.h b/config.def.h
index 0e01717..96d1bdd 100644
--- a/config.def.h
+++ b/config.def.h
@@ -1,3 +1,4 @@
+char *externalpipe_sigusr1[] = {"/bin/sh", "-c", "externalpipe_buffer.sh st_strings_read"};
 /* See LICENSE file for copyright and license details. */
 
 /*
diff --git a/st.c b/st.c
index b8e6077..48cae2e 100644
--- a/st.c
+++ b/st.c
@@ -155,6 +155,7 @@ typedef struct {
 static void execsh(char *, char **);
 static void stty(char **);
 static void sigchld(int);
+static void sigusr1(int);
 static void ttywriteraw(const char *, size_t);
 
 static void csidump(void);
@@ -719,6 +720,13 @@ execsh(char *cmd, char **args)
 	_exit(1);
 }
 
+void
+sigusr1(int unused)
+{
+  static Arg a = {.v = externalpipe_sigusr1};
+  externalpipe(&a);
+}
+
 void
 sigchld(int a)
 {
@@ -765,6 +773,12 @@ stty(char **args)
 int
 ttynew(char *line, char *cmd, char *out, char **args)
 {
+	static struct sigaction sa;
+	sa.sa_handler = sigusr1;
+	sigemptyset(&sa.sa_mask);
+	sa.sa_flags = SA_RESTART;
+	sigaction(SIGUSR1, &sa, NULL);
+
 	int m, s;
 
 	if (out) {
diff --git a/st.h b/st.h
index 38c61c4..794b4ff 100644
--- a/st.h
+++ b/st.h
@@ -111,6 +111,7 @@ void *xrealloc(void *, size_t);
 char *xstrdup(char *);
 
 /* config.h globals */
+extern char *externalpipe_sigusr1[];
 extern char *utmp;
 extern char *stty_args;
 extern char *vtiden;
-- 
2.19.2