Merge branch 'master' into experimental - sam - An updated version of the sam text editor.
(HTM) git clone git://vernunftzentrum.de/sam.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit 84b051c7d9d429d3f6dda596a9d01e9a85652c82
(DIR) parent 97562b07dcb8e2eca6523d2820f504275c6a9bb4
(HTM) Author: Rob King <jking@deadpixi.com>
Date: Thu, 20 Oct 2016 17:11:56 -0500
Merge branch 'master' into experimental
Diffstat:
rsam/rsam.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
---
(DIR) diff --git a/rsam/rsam.c b/rsam/rsam.c
@@ -20,6 +20,7 @@
#define CHILD_READ writepipe[0]
#define PARENT_WRITE writepipe[1]
#define MAX(x, y) ((x) > (y) ? (x) : (y))
+#define CHECKEDWRITE(f, b, c) if (write(f, b, c) != c) exit(EXIT_FAILURE)
char path[PATH_MAX + 1];
@@ -92,7 +93,7 @@ main(int argc, char **argv)
count = read(STDIN_FILENO, buf, 8192);
if (count <= 0)
exit(EXIT_SUCCESS);
- write(PARENT_WRITE, buf, count);
+ CHECKEDWRITE(PARENT_WRITE, buf, count);
}
if (FD_ISSET(fifo, &rfds)){
@@ -100,15 +101,15 @@ main(int argc, char **argv)
count = read(fifo, buf, 253);
if (count <= 0)
exit(EXIT_SUCCESS);
- write(STDOUT_FILENO, "\x19\xff\x00", 3);
- write(STDOUT_FILENO, buf, 255);
+ CHECKEDWRITE(STDOUT_FILENO, "\x19\xff\x00", 3);
+ CHECKEDWRITE(STDOUT_FILENO, buf, 255);
}
if (FD_ISSET(PARENT_READ, &rfds)){
count = read(PARENT_READ, buf, 8192);
if (count <= 0)
exit(EXIT_SUCCESS);
- write(STDOUT_FILENO, buf, count);
+ CHECKEDWRITE(STDOUT_FILENO, buf, count);
}
FD_ZERO(&rfds);