Job-Control

“fg”代表什麼?

  • March 17, 2017

ctrl-z 或 fg 沒有手動輸入。

在作業控制的上下文中,“fg”代表什麼?換句話說,輸入 ctrl-z 將暫停目前作業,將我放回 shell,命令“fg”重新啟動暫停的作業。“fg”代表什麼?

前景。

與其他 bash built-ins一樣,有 help

$ help fg
fg: fg [job_spec]
   Move job to the foreground.

   Place the job identified by JOB_SPEC in the foreground, making it the
   current job.  If JOB_SPEC is not present, the shell's notion of the
   current job is used.

   Exit Status:
   Status of command placed in foreground, or failure if an error occurs.
$ 

此外,bgisBackGround和 ^z 在bash手冊頁中,在 Job Control 下:

  If  the operating system on which bash is running supports job control,
  bash contains facilities to use it.  Typing the suspend character (typ‐
  ically ^Z, Control-Z) while a process is running causes that process to
  be stopped and returns control to bash.   Typing  the  delayed  suspend
  character  (typically  ^Y,  Control-Y) causes the process to be stopped
  when it attempts to read input from the terminal,  and  control  to  be
  returned  to bash.  The user may then manipulate the state of this job,
  using the bg command to continue it in the background, the  fg  command
  to continue it in the foreground, or the kill command to kill it.  A ^Z
  takes effect immediately, and has the additional side effect of causing
  pending output and typeahead to be discarded.

引用自:https://unix.stackexchange.com/questions/352032