-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathvterm_reply.c
More file actions
41 lines (30 loc) · 852 Bytes
/
Copy pathvterm_reply.c
File metadata and controls
41 lines (30 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <termios.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include "vterm_reply.h"
#include "vterm_private.h"
void
vterm_reply_buffer(vterm_t *vterm)
{
ssize_t bytes_written = 0;
if(vterm == NULL) return;
if(vterm->reply_buf_sz <= 0) return;
for(;;)
{
bytes_written = write(vterm->pty_fd, vterm->reply_buf,
vterm->reply_buf_sz);
// force a drain on the pty fd after every write
tcdrain(vterm->pty_fd);
if(bytes_written == 0) continue;
// on some errors, we just need to retry
if(bytes_written < 0)
{
if(errno == EINTR) continue;
if(errno == EAGAIN) continue;
}
vterm->reply_buf_sz -= bytes_written;
if(vterm->reply_buf_sz == 0) break;
}
return;
}