----
- st.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
- 1 file changed, 68 insertions(+), 6 deletions(-)
-
diff --git a/st.c b/st.c
-index 4fb3311..adef257 100644
+index 686ed5d..697cd43 100644
--- a/st.c
+++ b/st.c
-_AT_@ -299,6 +299,7 @@ typedef union {
+_AT_@ -249,6 +249,7 @@ typedef union {
unsigned int ui;
float f;
const void *v;
_AT_@ -19,7 +10,7 @@ index 4fb3311..adef257 100644
} Arg;
typedef struct {
-_AT_@ -313,6 +314,7 @@ static void clippaste(const Arg *);
+_AT_@ -263,6 +264,7 @@ static void clippaste(const Arg *);
static void numlock(const Arg *);
static void selpaste(const Arg *);
static void xzoom(const Arg *);
_AT_@ -27,14 +18,14 @@ index 4fb3311..adef257 100644
/* Config.h for applying patches and the configuration. */
#include "config.h"
-_AT_@ -1204,15 +1206,22 @@ execsh(void) {
+_AT_@ -1024,15 +1026,22 @@ execsh(void) {
void
sigchld(int a) {
int stat = 0;
+ pid_t r;
- if(waitpid(pid, &stat, 0) < 0)
-- die("Waiting for pid %hd failed: %s
", pid, SERRNO);
+- die("Waiting for pid %hd failed: %s
", pid, SERRNO);
+ r = wait(&stat);
+ if(r < 0)
+ die("wait(): %s
", SERRNO);
_AT_@ -44,7 +35,7 @@ index 4fb3311..adef257 100644
- } else {
- exit(EXIT_FAILURE);
+ if(r == pid){
-+ /* _the_ sub porcess */
++ /* _the_ sub process */
+ if(WIFEXITED(stat)) {
+ exit(WEXITSTATUS(stat));
+ } else {
_AT_@ -56,7 +47,7 @@ index 4fb3311..adef257 100644
}
void
-_AT_@ -2928,6 +2937,59 @@ xzoom(const Arg *arg) {
+_AT_@ -2593,6 +2602,59 @@ xzoom(const Arg *arg) {
}
void
_AT_@ -114,8 +105,5 @@ index 4fb3311..adef257 100644
+
+void
xinit(void) {
+ XSetWindowAttributes attrs;
XGCValues gcvalues;
- Cursor cursor;
---
-1.7.10.4
-
diff --git a/st.suckless.org/patches/st-0.5-externalpipe.diff b/st.suckless.org/patches/st-0.5-externalpipe.diff
new file mode 100644
index 0000000..8a1ef05
--- /dev/null
+++ b/st.suckless.org/patches/st-0.5-externalpipe.diff
_AT_@ -0,0 +1,109 @@
+diff --git a/st.c b/st.c
+index 392f12d..31660c8 100644
+--- a/st.c
++++ b/st.c
+_AT_@ -301,6 +301,7 @@ typedef union {
+ unsigned int ui;
+ float f;
+ const void *v;
++ const char *s;
+ } Arg;
+
+ typedef struct {
+_AT_@ -315,6 +316,7 @@ static void clippaste(const Arg *);
+ static void numlock(const Arg *);
+ static void selpaste(const Arg *);
+ static void xzoom(const Arg *);
++static void externalpipe(const Arg *);
+ static void printsel(const Arg *);
+ static void printscreen(const Arg *) ;
+ static void toggleprinter(const Arg *);
+_AT_@ -1179,15 +1181,22 @@ execsh(void) {
+ void
+ sigchld(int a) {
+ int stat = 0;
++ pid_t r;
+
+- if(waitpid(pid, &stat, 0) < 0)
+- die("Waiting for pid %hd failed: %s
", pid, SERRNO);
++ r = wait(&stat);
++ if(r < 0)
++ die("wait(): %s
", strerror(errno));
+
+- if(WIFEXITED(stat)) {
+- exit(WEXITSTATUS(stat));
+- } else {
+- exit(EXIT_FAILURE);
++ if(r == pid){
++ /* _the_ sub process */
++ if(WIFEXITED(stat)) {
++ exit(WEXITSTATUS(stat));
++ } else {
++ exit(EXIT_FAILURE);
++ }
+ }
++
++ /* something else we've forked out */
+ }
+
+ void
+_AT_@ -2982,6 +2991,59 @@ xzoom(const Arg *arg) {
+ }
+
+ void
++externalpipe(const Arg *arg)
++{
++ int to[2]; /* 0 = read, 1 = write */
++ pid_t child;
++ int y, x;
++ void (*oldsigpipe)(int);
++
++ if(pipe(to) == -1)
++ return;
++
++ /* sigchld() handles this */
++ switch((child = fork())){
++ case -1:
++ close(to[0]), close(to[1]);
++ return;
++ case 0:
++ /* child */
++ close(to[1]);
++ dup2(to[0], STDIN_FILENO); /* 0<&to */
++ close(to[0]);
++ execvp(
++ "sh",
++ (char *const []){
++ "/bin/sh",
++ "-c",
++ (char *)arg->s,
++ 0
++ });
++ exit(127);
++ }
++
++ /* parent */
++ close(to[0]);
++ /* ignore sigpipe for now, in case child exits early */
++ oldsigpipe = signal(SIGPIPE, SIG_IGN);
++
++ for(y = 0; y < term.row; y++){
++ for(x = 0; x < term.col; x++){
++ if(write(to[1], term.line[y][x].c, 1) == -1)
++ goto done;
++ }
++ if(write(to[1], "
", 1) == -1)
++ break;
++ }
++
++done:
++ close(to[1]);
++
++ /* restore */
++ signal(SIGPIPE, oldsigpipe);
++}
++
++void
+ xinit(void) {
+ XGCValues gcvalues;
+ Cursor cursor;
diff --git a/st.suckless.org/patches/st-git-20150824-externalpipe.diff b/st.suckless.org/patches/st-git-20150824-externalpipe.diff
deleted file mode 100644
index 2815ab6..0000000
--- a/st.suckless.org/patches/st-git-20150824-externalpipe.diff
+++ /dev/null
_AT_@ -1,75 +0,0 @@
-diff --git a/st.c b/st.c
-index 35a840b..bb2dd17 100644
---- a/st.c
-+++ b/st.c
-_AT_@ -327,6 +327,7 @@ static void clipcopy(const Arg *);
- static void clippaste(const Arg *);
- static void numlock(const Arg *);
- static void selpaste(const Arg *);
-+static void externalpipe(const Arg *);
- static void xzoom(const Arg *);
- static void xzoomabs(const Arg *);
- static void xzoomreset(const Arg *);
-_AT_@ -2888,6 +2889,62 @@ eschandle(uchar ascii)
- }
-
- void
-+externalpipe(const Arg *arg)
-+{
-+ int to[2]; /* 0 = read, 1 = write */
-+ pid_t child;
-+ int n;
-+ void (*oldsigpipe)(int);
-+ char buf[UTF_SIZ];
-+ Glyph *bp, *end;
-+
-+ if(pipe(to) == -1)
-+ return;
-+
-+ /* sigchld() handles this */
-+ switch(child = fork()){
-+ case -1:
-+ close(to[0]), close(to[1]);
-+ return;
-+ case 0:
-+ /* child */
-+ close(to[1]);
-+ dup2(to[0], STDIN_FILENO); /* 0<&to */
-+ close(to[0]);
-+ execvp(
-+ "sh",
-+ (char *const []){
-+ "/bin/sh",
-+ "-c",
-+ (char *)arg->v,
-+ 0
-+ });
-+ exit(127);
-+ }
-+
-+ /* parent */
-+ close(to[0]);
-+ /* ignore sigpipe for now, in case child exits early */
-+ oldsigpipe = signal(SIGPIPE, SIG_IGN);
-+
-+ for(n = 0; n < term.row; n++){
-+ bp = &term.line[n][0];
-+ end = &bp[MIN(tlinelen(n), term.col) - 1];
-+ if(bp != end || bp->u != ' ')
-+ for(; bp <= end; ++bp)
-+ if(xwrite(to[1], buf, utf8encode(bp->u, buf)) < 0)
-+ break;
-+ if(xwrite(to[1], "
", 1) < 0)
-+ break;
-+ }
-+
-+ close(to[1]);
-+
-+ /* restore */
-+ signal(SIGPIPE, oldsigpipe);
-+}
-+
-+void
- tputc(Rune u)
- {
- char c[UTF_SIZ];
diff --git a/st.suckless.org/patches/st-git-20150917-externalpipe.diff b/st.suckless.org/patches/st-git-20150917-externalpipe.diff
new file mode 100644
index 0000000..c6744bc
--- /dev/null
+++ b/st.suckless.org/patches/st-git-20150917-externalpipe.diff
_AT_@ -0,0 +1,75 @@
+diff --git a/st.c b/st.c
+index bd8b815..a43e615 100644
+--- a/st.c
++++ b/st.c
+_AT_@ -328,6 +328,7 @@ static void clipcopy(const Arg *);
+ static void clippaste(const Arg *);
+ static void numlock(const Arg *);
+ static void selpaste(const Arg *);
++static void externalpipe(const Arg *);
+ static void xzoom(const Arg *);
+ static void xzoomabs(const Arg *);
+ static void xzoomreset(const Arg *);
+_AT_@ -2920,6 +2921,62 @@ eschandle(uchar ascii)
+ }
+
+ void
++externalpipe(const Arg *arg)
++{
++ int to[2]; /* 0 = read, 1 = write */
++ pid_t child;
++ int n;
++ void (*oldsigpipe)(int);
++ char buf[UTF_SIZ];
++ Glyph *bp, *end;
++
++ if(pipe(to) == -1)
++ return;
++
++ /* sigchld() handles this */
++ switch(child = fork()){
++ case -1:
++ close(to[0]), close(to[1]);
++ return;
++ case 0:
++ /* child */
++ close(to[1]);
++ dup2(to[0], STDIN_FILENO); /* 0<&to */
++ close(to[0]);
++ execvp(
++ "sh",
++ (char *const []){
++ "/bin/sh",
++ "-c",
++ (char *)arg->v,
++ 0
++ });
++ exit(127);
++ }
++
++ /* parent */
++ close(to[0]);
++ /* ignore sigpipe for now, in case child exits early */
++ oldsigpipe = signal(SIGPIPE, SIG_IGN);
++
++ for(n = 0; n < term.row; n++){
++ bp = &term.line[n][0];
++ end = &bp[MIN(tlinelen(n), term.col) - 1];
++ if(bp != end || bp->u != ' ')
++ for(; bp <= end; ++bp)
++ if(xwrite(to[1], buf, utf8encode(bp->u, buf)) < 0)
++ break;
++ if(xwrite(to[1], "
", 1) < 0)
++ break;
++ }
++
++ close(to[1]);
++
++ /* restore */
++ signal(SIGPIPE, oldsigpipe);
++}
++
++void
+ tputc(Rune u)
+ {
+ char c[UTF_SIZ];
Received on Thu Sep 17 2015 - 16:49:39 CEST
This archive was generated by hypermail 2.3.0 : Thu Sep 17 2015 - 17:00:15 CEST