Refactor, wrap write() syscall in new dprint() function

Fixes the GCC warning for unchecked return value from write():

  ... ignoring return value of ‘write’, declared with attribute warn_unused_result

The new dprint() function wraps write() in a bounded retry-loop that
catches EINTR.  The length argument is optional computed with strlen()
if omitted (zero).

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2021-04-04 12:35:35 +02:00
1 parent c84c17ea8c
commit 5342881bf4
5 files changed
+41 -24

No files matched your search

+4 -2
View File
@@ -27,6 +27,8 @@
#include <sys/ttydefaults.h> /* Not included by default in musl libc */
#include <termios.h>
#include <helpers.h>
/* B0 means; keep kernel default */
speed_t stty_parse_speed(char *baud)
{
@@ -123,10 +125,10 @@ void stty(int fd, speed_t speed)
tcsetattr(fd, TCSAFLUSH, &term);
/* Show cursor again, if it was hidden previously */
write(fd, "\033[?25h", 6);
dprint(fd, "\033[?25h", 6);
/* Enable line wrap, if disabled previously */
write(fd, "\033[7h", 4);
dprint(fd, "\033[7h", 4);
}
/**