char *newline = NULL;
if(!fd)
-abort();
+ abort();
+
while(!(newline = memchr(buffer, '\n', blen))) {
int result = recv(fd, buffer + blen, sizeof buffer - blen, 0);
if(result == -1 && errno == EINTR)
return 0;
}
+#ifdef SIGINT
+static void sigint_handler(int sig) {
+ fprintf(stderr, "\n");
+ shutdown(fd, SHUT_RDWR);
+}
+#endif
+
static int cmd_log(int argc, char *argv[]) {
if(argc > 2) {
fprintf(stderr, "Too many arguments!\n");
if(!connect_tincd(true))
return 1;
+#ifdef SIGINT
+ signal(SIGINT, sigint_handler);
+#endif
+
logcontrol(fd, stdout, argc > 1 ? atoi(argv[1]) : -1);
+
+#ifdef SIGINT
+ signal(SIGINT, SIG_DFL);
+#endif
+
+ close(fd);
+ fd = -1;
return 0;
}