Not receiving stdout from nodejs spawned process

后端 未结 3 1845
青春惊慌失措
青春惊慌失措 2021-02-13 11:08

I\'m trying to have nodejs interact with adventure, an old text based game. The idea is to open adventure as a child process and then play the game by writing

3条回答
  •  [愿得一人]
    2021-02-13 11:21

    Why isn't that initial line from the game being picked up?

    I had the same problem on a project that called a compiled C++ program from node.js. I realized the problem was in the compiled C++ program: I wasn't flushing the stdout stream. Adding fflush(stdout); after printing a line solved the issue. Hopefully you still have access to the source of the game!

提交回复
热议问题