Handle EOF to allow redirection of stdin

pull/1/head
Jonathan Brandenburg 8 years ago
parent 906f127f5f
commit d3d2449ac7

@ -189,7 +189,7 @@ void *receive(void *arg) {
exit(EXIT_FAILURE);
}
usleep(100000);
usleep(25000);
}
return NULL;
@ -273,6 +273,8 @@ void *transmit(void *arg) {
fprintf(stderr, "Failed to post on semaphore with error %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
usleep(200000);
}
return NULL;
@ -290,6 +292,12 @@ int get_message(uint8_t *buffer, int avail) {
}
fgets((char *)buffer, avail, stdin);
// check for end-of-file (for redirecting stdin)
if (feof(stdin)) {
buffer[0] = '\n';
buffer[1] = 0;
}
// If the newline isn't present, the message is too long
//printf("DEBUG: ***%s***\n", buffer);

Loading…
Cancel
Save

Powered by TurnKey Linux.