Skip to content

Commit 2cf4235

Browse files
authored
Merge pull request #1424 from ahmadgamal15-art/fix/windows-stdio-binary-mode
fix(mcp): set stdio to binary mode on Windows
2 parents 6a5f850 + 53ce82f commit 2cf4235

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎src/mcp/mcp.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11652,6 +11652,13 @@ static int poll_for_input_unix(cbm_mcp_server_t *srv, int fd, FILE *in) {
1165211652
int cbm_mcp_server_run(cbm_mcp_server_t *srv, FILE *in, FILE *out) {
1165311653
int fd = cbm_fileno(in);
1165411654

11655+
#ifdef _WIN32
11656+
/* Ensure stdio is in binary mode to prevent CRLF translation from corrupting
11657+
* Content-Length byte counts and causing fread() to hang. */
11658+
_setmode(cbm_fileno(in), _O_BINARY);
11659+
_setmode(cbm_fileno(out), _O_BINARY);
11660+
#endif
11661+
1165511662
for (;;) {
1165611663
/* Poll with idle timeout so we can evict unused stores between requests.
1165711664
*

0 commit comments

Comments
 (0)