sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

st-externalpipe-signal-0.8.2.diff (1705B)


      1 From df32a82e8a889629ed406ce468f24c35da7e9a03 Mon Sep 17 00:00:00 2001
      2 From: Miles Alan <m@milesalan.com>
      3 Date: Sun, 11 Aug 2019 21:33:55 -0500
      4 Subject: [PATCH] Add handler for SIGUSR1 signal to run an externalpipe command
      5 
      6 ---
      7  config.def.h |  1 +
      8  st.c         | 14 ++++++++++++++
      9  st.h         |  1 +
     10  3 files changed, 16 insertions(+)
     11 
     12 diff --git a/config.def.h b/config.def.h
     13 index 0e01717..96d1bdd 100644
     14 --- a/config.def.h
     15 +++ b/config.def.h
     16 @@ -1,3 +1,4 @@
     17 +char *externalpipe_sigusr1[] = {"/bin/sh", "-c", "externalpipe_buffer.sh st_strings_read"};
     18  /* See LICENSE file for copyright and license details. */
     19  
     20  /*
     21 diff --git a/st.c b/st.c
     22 index b8e6077..48cae2e 100644
     23 --- a/st.c
     24 +++ b/st.c
     25 @@ -155,6 +155,7 @@ typedef struct {
     26  static void execsh(char *, char **);
     27  static void stty(char **);
     28  static void sigchld(int);
     29 +static void sigusr1(int);
     30  static void ttywriteraw(const char *, size_t);
     31  
     32  static void csidump(void);
     33 @@ -719,6 +720,13 @@ execsh(char *cmd, char **args)
     34  	_exit(1);
     35  }
     36  
     37 +void
     38 +sigusr1(int unused)
     39 +{
     40 +  static Arg a = {.v = externalpipe_sigusr1};
     41 +  externalpipe(&a);
     42 +}
     43 +
     44  void
     45  sigchld(int a)
     46  {
     47 @@ -765,6 +773,12 @@ stty(char **args)
     48  int
     49  ttynew(char *line, char *cmd, char *out, char **args)
     50  {
     51 +	static struct sigaction sa;
     52 +	sa.sa_handler = sigusr1;
     53 +	sigemptyset(&sa.sa_mask);
     54 +	sa.sa_flags = SA_RESTART;
     55 +	sigaction(SIGUSR1, &sa, NULL);
     56 +
     57  	int m, s;
     58  
     59  	if (out) {
     60 diff --git a/st.h b/st.h
     61 index 38c61c4..794b4ff 100644
     62 --- a/st.h
     63 +++ b/st.h
     64 @@ -111,6 +111,7 @@ void *xrealloc(void *, size_t);
     65  char *xstrdup(char *);
     66  
     67  /* config.h globals */
     68 +extern char *externalpipe_sigusr1[];
     69  extern char *utmp;
     70  extern char *stty_args;
     71  extern char *vtiden;
     72 -- 
     73 2.19.2
     74