Skip to content

Commit 9aa4a60

Browse files
Xiangfu LiuSebastien Bourdeauducq
Xiangfu Liu
authored and
Sebastien Bourdeauducq
committedAug 25, 2011
tools: flterm: check logfd, check ascii, flush each line
1 parent 2353955 commit 9aa4a60

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed
 

‎tools/flterm.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <sys/ioctl.h>
2525
#include <sys/time.h>
2626
#include <string.h>
27+
#include <ctype.h>
2728
#include <termios.h>
2829
#include <fcntl.h>
2930
#include <unistd.h>
@@ -492,8 +493,10 @@ static void do_terminal(char *serial_port,
492493
if(fds[1].revents & POLLIN) {
493494
if(read(serialfd, &c, 1) <= 0) break;
494495

495-
fwrite(&c, sizeof(c), 1, logfd);
496-
fflush(logfd);
496+
if(logfd != NULL) {
497+
if(isascii(c)) fwrite(&c, sizeof(c), 1, logfd);
498+
if(c == '\n') fflush(logfd);
499+
}
497500

498501
if(gdbfd != -1 && rsp_pending && (c == '+' || c == '-')) {
499502
rsp_pending = 0;

0 commit comments

Comments
 (0)
Please sign in to comment.