Introduction
Introduction Statistics Contact Development Disclaimer Help
Fix support for using sockets insteads of pipes - blind - suckless command-line…
git clone git://git.suckless.org/blind
Log
Files
Refs
README
LICENSE
---
commit d391ca2ddb719d2478e824dec082b849613eeda6
parent 3b3646effb548d2af894422f2123dd7976d7f1af
Author: Mattias Andrée <[email protected]>
Date: Sun, 23 Jul 2017 22:55:14 +0200
Fix support for using sockets insteads of pipes
Signed-off-by: Mattias Andrée <[email protected]>
Diffstat:
M src/blind-coordinate-field.c | 3 +--
M src/blind-single-colour.c | 3 +--
M src/blind-tee.c | 2 ++
M src/util/efunc.h | 12 ++++++++++++
4 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/src/blind-coordinate-field.c b/src/blind-coordinate-field.c
@@ -64,8 +64,7 @@ PROCESS(void)
buf[1] = (TYPE)y;
for (x = 0; x < stream.width; x++) {
buf[0] = (TYPE)x;
- if (write(STDOUT_FILENO, buf, sizeof(buf)) < 0)
- eprintf("write <stdout>:");
+ ewrite(STDOUT_FILENO, buf, sizeof(buf), "<stdo…
}
}
}
diff --git a/src/blind-single-colour.c b/src/blind-single-colour.c
@@ -86,8 +86,7 @@ PROCESS(void)
for (y = stream.height; y--;)
for (x = stream.width * sizeof(*buf); x;)
for (x -= n = MIN(sizeof(buf), x); n; n -= (si…
- if ((r = write(STDOUT_FILENO, buf, n))…
- eprintf("write <stdout>:");
+ r = ewrite(STDOUT_FILENO, buf, n, "<st…
}
#endif
diff --git a/src/blind-tee.c b/src/blind-tee.c
@@ -13,6 +13,8 @@ main(int argc, char *argv[])
UNOFLAGS(0);
+ signal(SIGPIPE, SIG_IGN);
+
fds[n++] = STDOUT_FILENO;
while (argc--)
fds[n++] = eopen(*argv++, O_WRONLY | O_CREAT | O_TRUNC, 0666);
diff --git a/src/util/efunc.h b/src/util/efunc.h
@@ -64,6 +64,18 @@ epread(int fd, void *buf, size_t n, off_t off, const char *f…
return (size_t)ret;
}
+static inline size_t
+ewrite(int fd, void *buf, size_t n, const char *fname)
+{
+ ssize_t ret = write(fd, buf, n);
+ if (ret < 0) {
+ if (errno = ECONNRESET)
+ raise(SIGPIPE);
+ eprintf("write %s:", fname);
+ }
+ return (size_t)ret;
+}
+
static inline off_t
elseek(int fd, off_t offset, int whence, const char *fname)
{
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.