bashクックブック
ISBN:9784873113760
P216
nohup hoge.sh 0<&- 1>/dev/null 2>&1 &
標準入出力を切り離しているので、最低限にはなるようだ。
http://oshiete1.watch.impress.co.jp/qa1059932.html
Linuxの標準シェルであるbashの場合、&するだけで制御端末も切り離してしまうようです。この仕様はUNIX全般で通用しないものとして考える方がよいと思います。
(中略)
一般的には、起動したシェルスクリプト、もしくはプログラム本体が決められたファイルにPIDを出力しておき、終了用のシェルスクリプト(普通は起動と終了を行う一つのスクリプトになります)は、そこに書かれているPIDに対してkillします。
プログラム本体は、シグナルをトラップしており、killで送られたSIGTERM等をトリガーとして、自分自身を正しく終了させる処理を行います。
めも
disownというbash組込コマンドもあるようだが、
どちらかと言うと後からバックグラウンドにしたジョブをデーモン化するコマンドのようだ。
disown [-ar] [-h] [jobspec ...]
Without options, each jobspec is removed from the table of active jobs. If the -h
option is given, each jobspec is not removed from the table, but is marked so that
SIGHUP is not sent to the job if the shell receives a SIGHUP. If no jobspec is
present, and neither the -a nor the -r option is supplied, the current job is used.
If no jobspec is supplied, the -a option means to remove or mark all jobs; the -r
option without a jobspec argument restricts operation to running jobs. The return
value is 0 unless a jobspec does not specify a valid job.
詳細未調査
http://blog.glidenote.com/blog/2013/09/26/bg-and-disown/
rpmbuild -ba hoge.spec # Ctrl+Zで中断 bg 1 jobs 1 disown %1
めも、未検証