Skip to content

Commit 8ecff9e

Browse files
author
chenchacha
committed
Fix a bug: Occasionally the program crashes when executing run_builtin_cmd()
Signed-off-by: chenchacha <chen.chenchacha@foxmail.com>
1 parent a127445 commit 8ecff9e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/server.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ cJSON * run_builtin_cmd(jrpc_context * ctx, cJSON * params, cJSON *id)
203203

204204
int bak_fd = dup(STDOUT_FILENO);
205205
int new_fd = dup2(fd[1], STDOUT_FILENO);
206+
fflush(bak_fd);
206207
func(argc, argv);
207208
int size = read(fd[0], cmd_buff, CMD_BUFF- strlen(endstring) - 1);
208209

0 commit comments

Comments
 (0)