what does "bash:no job control in this shell” mean?

后端 未结 4 1134
感情败类
感情败类 2020-12-07 14:02

I think it\'s related to the parent process creating new subprocess and does not have tty. Can anyone explain the detail under the hood? i.e. the related working model of ba

4条回答
  •  Happy的楠姐
    2020-12-07 14:42

    One of the possible options would be not having access to the tty.

    Under the hood:

    1. bash checks whether the session is interactive, if not - no job control.
    2. if forced_interactive is set, then check that stderr is attached to a tty is skipped and bash checks again, whether in can open /dev/tty for read-write access.
    3. then it checks whether new line discipline is used, if not, then job control is disabled too.
    4. If (and only if) we just set our process group to our pid, thereby becoming a process group leader, and the terminal is not in the same process group as our (new) process group, then set the terminal's process group to our (new) process group. If that fails, set our process group back to what it was originally (so we can still read from the terminal) and turn off job control.
    5. if all of the above has failed, you see the message.

    I partially quoted the comments from bash source code.

    [edit]

    As per additional request of the question author:

    http://tiswww.case.edu/php/chet/bash/bashtop.html Here you can find bash itself.

    If you can read the C code, get the source tarball, inside it you will find job.c - that one will explain you more "under the hood" stuff. :)

提交回复
热议问题