ablog

不器用で落着きのない技術者のメモ

「jobs -l」実行したときの「+」とか「-」ってなんだろ?

-bash-3.00$ jobs -l
[1]   7328 Running                 tail -f a &
[2]-  7339 Running                 perl -e 'while(1) {}' &
[3]+  7535 Running                 tail -f a &

↑の「-」とか「+」とかは何を意味するんだろう?

手元の Solaris 10 でちょっと確認してみた。

-bash-3.00$ cat /etc/release 
                   Oracle Solaris 10 9/10 s10s_u9wos_14a SPARC
     Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
                            Assembled 11 August 2010
-bash-3.00$ man jobs
     the job number in brackets and a list of associated  process
     numbers:

          [1] 1234

     To see the current list of jobs, use the jobs built-in  com-
     mand.  The  job most recently stopped (or put into the back-
     ground if none are stopped) is referred to  as  the  current
     job  and  is indicated with a `+'. The previous job is indi-
     cated with a `-'; when the  current  job  is  terminated  or
     moved  to  the foreground, this job takes its place (becomes
     the new current job).

man で見てみると、「+」は最後に一時停止(SIGSTOP)もしくはバックグラウンドで実行されたジョブで、「-」はその一つ前のジョブらしい。