Ensure fd is blocking in thread_write()

This commit is contained in:
Kovid Goyal 2019-06-12 20:42:17 +05:30
parent f151f4c165
commit 91bf9f2ec8
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -770,6 +770,10 @@ static void*
thread_write(void *x) {
ThreadWriteData *data = (ThreadWriteData*)x;
set_thread_name("KittyWriteStdin");
int flags = fcntl(data->fd, F_GETFL, 0);
if (flags == -1) { free_twd(data); return 0; }
flags &= ~O_NONBLOCK;
fcntl(data->fd, F_SETFL, flags);
FILE *f = fdopen(data->fd, "w");
if (fwrite(data->buf, 1, data->sz, f) != data->sz) {
log_error("Failed to write all data");