Add write_poll to improve tty_write and tty_sync

Implement blockable write with poll + nonblock write.
This commit is contained in:
yabu76 2025-12-30 20:19:26 +09:00
parent b5656112d7
commit eab0f6245b
4 changed files with 62 additions and 10 deletions

View file

@ -24,6 +24,7 @@
#include <stdbool.h>
#include <stdio.h>
#define WRITE_POLL_FOREVER (-1)
#define UNUSED(expr) do { (void)(expr); } while (0)
void delay(long ms);
@ -32,6 +33,7 @@ bool regex_match(const char *string, const char *pattern);
unsigned long djb2_hash(const unsigned char *str);
void *base62_encode(unsigned long num, char *output);
int read_poll(int fd, void *data, size_t len, int timeout);
ssize_t write_poll(int fd, const void *data, size_t len, int timeout);
double get_current_time(void);
bool match_patterns(const char *string, const char *patterns);
int execute_shell_command(int fd, const char *command);