aboutsummaryrefslogtreecommitdiff
path: root/norns_shell.c
diff options
context:
space:
mode:
authorgretchen <gretchen@gnar.cool>2019-11-17 22:30:53 -0800
committergretchen <gretchen@gnar.cool>2019-11-17 22:30:53 -0800
commite03849c6c7c0b224c78612186e31032edb3b6231 (patch)
tree88dea901fca010ff85031fa6844066870a61ab27 /norns_shell.c
parent51bb17e9d13796c83b3a6e96f71f38263f6b7b4f (diff)
downloadnorns-etc-e03849c6c7c0b224c78612186e31032edb3b6231.tar.gz
norns-etc-e03849c6c7c0b224c78612186e31032edb3b6231.zip
two TODOs; EOF handling.
Diffstat (limited to 'norns_shell.c')
-rw-r--r--norns_shell.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/norns_shell.c b/norns_shell.c
index fbd556c..fc7867d 100644
--- a/norns_shell.c
+++ b/norns_shell.c
@@ -89,6 +89,7 @@ int main (int argc, char **argv)
int received = 0;
struct timespec sent_sentinel = {0};
+ /* TODO wait for responses before exiting after EOF */
struct nn_pollfd poll_s = { .fd = s, .events = NN_POLLIN | NN_POLLOUT };
while (!killed) {
switch (nn_poll(&poll_s, 1, 1000)) {
@@ -153,13 +154,14 @@ int main (int argc, char **argv)
fprintf(stderr, "Can't read: %m\n");
goto error;
}
- /* treat EAGAIN as "read 0" */
- n = 0;
}
+ if (n == 0) goto finish;
+ /* treat EAGAIN as "read 0" */
+ if (n < 1) n = 0;
line_n += n;
if (line_n >= 1 && line[line_n - 1] == '\n') {
if ((nn_send(s, line, line_n, 0)) != line_n) {
- fprintf(stderr, "Couldn't send: %m\n");
+ fprintf(stderr, "Can't send: %m\n");
goto error;
}
line_n = 0;