surf-externalpipe-signal-2.0.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
surf-externalpipe-signal-2.0.diff (1772B)
---
1 From 84a41d036329c7599024b7cb0f613400d7484cec Mon Sep 17 00:00:00 2001
2 From: Miles Alan <m@milesalan.com>
3 Date: Sun, 11 Aug 2019 21:36:58 -0500
4 Subject: [PATCH] Add handler for SIGUSR1 signal to run an externalpipe command
5
6 ---
7 config.def.h | 1 +
8 surf.c | 16 ++++++++++++++++
9 2 files changed, 17 insertions(+)
10
11 diff --git a/config.def.h b/config.def.h
12 index 6d3135e..a7363d9 100644
13 --- a/config.def.h
14 +++ b/config.def.h
15 @@ -5,6 +5,7 @@ static char *scriptfile = "~/.surf/script.js";
16 static char *styledir = "~/.surf/styles/";
17 static char *cachedir = "~/.surf/cache/";
18 static char *cookiefile = "~/.surf/cookies.txt";
19 +static char *externalpipe_sigusr1[] = {"/bin/sh", "-c", "externalpipe_buffer.sh surf_strings_read"};
20
21 /* Webkit default features */
22 static Parameter defconfig[ParameterLast] = {
23 diff --git a/surf.c b/surf.c
24 index 93a1629..0e402ca 100644
25 --- a/surf.c
26 +++ b/surf.c
27 @@ -146,6 +146,7 @@ static void die(const char *errstr, ...);
28 static void setup(void);
29 static void sigchld(int unused);
30 static void sighup(int unused);
31 +static void sigusr1(int unused);
32 static char *buildfile(const char *path);
33 static char *buildpath(const char *path);
34 static const char *getuserhomedir(const char *user);
35 @@ -338,6 +339,15 @@ sigchld(int unused)
36 ;
37 }
38
39 +void
40 +sigusr1(int unused)
41 +{
42 + static Arg a = {.v = externalpipe_sigusr1};
43 + Client *c;
44 + for (c = clients; c; c = c->next)
45 + externalpipe(c, &a);
46 +}
47 +
48 void
49 sighup(int unused)
50 {
51 @@ -1757,6 +1767,12 @@ main(int argc, char *argv[])
52 c = newclient(NULL);
53 showview(NULL, c);
54
55 + struct sigaction sa;
56 + sa.sa_handler = sigusr1;
57 + sigemptyset(&sa.sa_mask);
58 + sa.sa_flags = SA_RESTART;
59 + sigaction(SIGUSR1, &sa, NULL);
60 +
61 loaduri(c, &arg);
62 updatetitle(c);
63
64 --
65 2.19.2
66