What is difference between a job and a process in Unix?

后端 未结 8 1319
别跟我提以往
别跟我提以往 2021-02-02 10:53

What is the difference between a job and a process in Unix ? Can you please give an example ?

8条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-02 11:22

    Jobs are processes which are started by a shell. The shell keeps track of these in a job table. The jobs command shows a list of active background processes. They get a jobspec number which is not the pid of the process. Commands like fg use the jobspec id.

    In the spirit of Jürgen Hötzel's example:

    find $HOME | sort &
    [1] 15317
    $ jobs
    [1]+  Running                 find $HOME | sort &
    $ fg
    find $HOME | sort
      C-c C-z
    [1]+  Stopped                 find $HOME | sort
    $ bg 1
    [1]+ find $HOME | sort &
    

    Try the examples yourself and look at the man pages.

提交回复
热议问题