Javascript 在充当基本命令shell的节点中启动子进程的最佳方法?

Javascript 在充当基本命令shell的节点中启动子进程的最佳方法?,javascript,node.js,parent-child,ipc,child-process,Javascript,Node.js,Parent Child,Ipc,Child Process,我试图在节点中生成一个子进程,该进程本质上可以作为自己的shell运行。对于上下文,其思想是在repl中运行子进程。以下是我到目前为止的情况: const args = path.resolve(path.join(__dirname, "../fileBeingExecuted.js")); const spawnOptions = { stdio: ["inherit", "inherit", "inherit"

我试图在节点中生成一个子进程,该进程本质上可以作为自己的shell运行。对于上下文,其思想是在repl中运行子进程。以下是我到目前为止的情况:

const args = path.resolve(path.join(__dirname, "../fileBeingExecuted.js"));

const spawnOptions = { stdio: ["inherit", "inherit", "inherit", "ipc"] };

...(unrelated code)

spawn.on("close", () => {
   process.stdin.resume();
 });

我似乎做错了什么,因为当子进程退出时,父进程挂起,而不是恢复其操作。更令人担忧的是,
ctrl+d
同时关闭子进程和父进程,而我希望它只关闭子进程

这里有我遗漏的解决方案吗