commit 342c7da4bd2c60796d722970f82300b6d5ba0b42
parent 0c120307ca1ab613e63865c634d7e10ad67fb0ba
Author: zeertzjq <zeertzjq@outlook.com>
Date: Thu, 21 Dec 2023 10:39:10 +0800
fix(channel): use os_write() instead of fwrite() for stderr (#26689)
This handles EAGAIN.
Related #26688
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/nvim/channel.c b/src/nvim/channel.c
@@ -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;
}