首页 文章

Nodejs setsid()等价

提问于
浏览
1

我试图在nodejs中执行一个bash shell - 除了作业控制之外我一直在工作 . 我很确定这是因为生成的进程没有被设置为进程领导者 . 在C中,我能够通过调用setsid()来做到这一点 . 在nodejs中,我读到等效的是在生成新进程时设置选项'setsid:true' . 我是这样做的:

var child = spawn('/bin/bash', ['--login'], {stdio: [this.slave, this.slave, this.slave], env: {"TERM": "vt100"}, setsid: true});

但是我仍然收到消息"no job control in this shell" .
分配pty ttys002后的示例输出:

bash: no job control in this shell
Amandas-MacBook-Pro:puffshell amanda$ tty
/dev/ttys002
Amandas-MacBook-Pro:puffshell amanda$ 
Amandas-MacBook-Pro:puffshell amanda$ ps
  PID TTY           TIME CMD
  2055 ttys000    0:00.05 -bash
  2158 ttys000    0:00.01 /bin/bash
  2170 ttys000    0:00.11 puffd 
  2171 ttys000    0:00.01 /bin/bash --login
Amandas-MacBook-Pro:puffshell amanda$

总而言之,我的问题是:

  • 这是设置新进程的正确方法's session id? And if so, how do I definitively check that it is actually doing that correctly (as it seems to me like it is not - this is the only thing I' d想象会导致无作业控制,因为tty命令是pty设置正确的证据) .
  • 如果这种方法赢得't work, are there any alternatives to setsid() that don'吨涉及下载模块?如果没有,我会写一个c插件 .
    谢谢你的帮助!

1 回答

相关问题