/usr/bin/bash: Difference between revisions

Line 1,223: Line 1,223:


== SIGNALS ==
== SIGNALS ==
      When bash is interactive, in the absence of any traps, it ignores SIGTERM (so that  kill  0  does
bashが対話型の場合、トラップがなければSIGTERMは無視され(kill 0が対話型シェルを殺すことはない)、'''SIGINT'''はキャッチされて処理される(wait組み込み関数が割り込み可能になる)。 すべての場合において、bashは'''SIGQUIT'''を無視する。 ジョブ制御が有効な場合、bash は '''SIGTTIN'''、'''SIGTTOU'''、'''SIGTSTP''' を無視する。
      not kill an interactive shell), and SIGINT is caught and handled (so that the wait builtin is in‐
      terruptible).  In all cases, bash ignores SIGQUIT.  If job control is  in  effect,  bash  ignores
      SIGTTIN, SIGTTOU, and SIGTSTP.


      Non-builtin  commands  run  by bash have signal handlers set to the values inherited by the shell
bashが実行する非ビルティン・コマンドのシグナル・ハンドラは、シェルが親から継承した値に設定される。 ジョブ制御が有効でない場合、非同期コマンドは、これらの継承されたハンドラに加え、'''SIGINT'''と'''SIGQUIT'''も無視する。 コマンド置換の結果として実行されるコマンドは、キーボードから生成されるジョブ制御シグナル'''SIGTTIN'''、'''SIGTTOU'''、'''SIGTSTP'''を無視する。
      from its parent.  When job control is not in effect,  asynchronous  commands  ignore  SIGINT and
      SIGQUIT in  addition to these inherited handlers.  Commands run as a result of command substitu‐
      tion ignore the keyboard-generated job control signals SIGTTIN, SIGTTOU, and SIGTSTP.


      The shell exits by default upon receipt of a SIGHUP.  Before exiting, an  interactive  shell  re‐
シェルはデフォルトでは'''SIGHUP'''を受け取ると終了する。 終了する前に、対話型シェルは実行中または停止中のすべてのジョブに '''SIGHUP''' を再送する。 停止しているジョブは、'''SIGHUP''' を確実に受信するために '''SIGCONT''' が送られる。 シェルが特定のジョブにシグナルを送らないようにするには、 disown 組み込み関数でジョブテーブルからそのジョブを削除するか(後述の [[#SHELL BUILTIN COMMANDS|SHELL BUILTIN COMMANDS ]] を参照)、 disown -h を使って '''SIGHUP''' を受け取らないようにマークする必要がある。
      sends  the  SIGHUP to all jobs, running or stopped.  Stopped jobs are sent SIGCONT to ensure that
      they receive the SIGHUP.  To prevent the shell from sending the signal to a  particular  job,  it
      should  be removed from the jobs table with the disown builtin (see SHELL BUILTIN COMMANDS below)
      or marked to not receive SIGHUP using disown -h.


      If the huponexit shell option has been set with shopt, bash sends a SIGHUP to all  jobs  when  an
shoptでhuponexitシェルオプションが設定されている場合、対話型ログインシェルが終了すると、bashはすべてのジョブに'''SIGHUP'''を送信する。
      interactive login shell exits.


      If bash is waiting for a command to complete and receives a signal for which a trap has been set,
bashがコマンドの完了を待っているときに、トラップが設定されているシグナルを受信すると、コマンドが完了するまでトラップは実行されない。 bash wait 組み込み関数で非同期コマンドを待機している場合、トラップが設定されたシグナルを受信すると、wait 組み込み関数は直ちに 128 より大きい終了ステータスで戻り、その直後にトラップが実行される。
      the trap will not be executed until the command completes.  When bash is waiting for an asynchro‐
      nous  command  via the wait builtin, the reception of a signal for which a trap has been set will
      cause the wait builtin to return immediately with an exit status greater  than  128,  immediately
      after which the trap is executed.


== JOB CONTROL ==
== JOB CONTROL ==