fix(channel): use os_write() instead of fwrite() for stderr (#26689)

This handles EAGAIN.

Related #26688
This commit is contained in:
zeertzjq 2023-12-21 10:39:10 +08:00 committed by GitHub
parent 0c120307ca
commit 342c7da4bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,6 +30,7 @@
#include "nvim/message.h"
#include "nvim/msgpack_rpc/channel.h"
#include "nvim/msgpack_rpc/server.h"
#include "nvim/os/fs.h"
#include "nvim/os/os_defs.h"
#include "nvim/os/shell.h"
#include "nvim/path.h"
@ -574,7 +575,10 @@ size_t channel_send(uint64_t id, char *data, size_t len, bool data_owned, const
goto retfree;
}
// unbuffered write
written = len * fwrite(data, len, 1, stderr);
ptrdiff_t wres = os_write(STDERR_FILENO, data, len, false);
if (wres >= 0) {
written = (size_t)wres;
}
goto retfree;
}