Ran multiple instances of my program in the background at the same time, what do these return signs mean?

StackOverflow https://stackoverflow.com/questions/17458653

  •  02-06-2022
  •  | 
  •  

문제

I just kicked off a bunch of instances (17) of my program to test them running concurrently. This is what the terminal output looked like near the end.

    [9]   Done                    perl test.pl -a
    [10]   Done                    perl test.pl -a
    [11]   Done                    perl test.pl -a
    [12]   Done                    perl test.pl -a
    [13]   Done                    perl test.pl -a
    [14]   Done                    perl test.pl -a
    [15]   Done                    perl test.pl -a
    [16]-  Done                    perl test.pl -a
    [17]+  Done                    perl test.pl -a

The 17th was the last one. I was wondering, what does the [16]- and [17]+ mean? Just that they were the last two processes to finish?

도움이 되었습니까?

해결책

From §7.1 "Job Control Basics" in the Bash Reference Manual:

Job number n may be referred to as ‘%n’. The symbols ‘%%’ and ‘%+’ refer to the shell’s notion of the current job, which is the last job stopped while it was in the foreground or started in the background. A single ‘%’ (with no accompanying job specification) also refers to the current job. The previous job may be referenced using ‘%-’. If there is only a single job, ‘%+’ and ‘%-’ can both be used to refer to that job. In output pertaining to jobs (e.g., the output of the jobs command), the current job is always flagged with a ‘+’, and the previous job with a ‘-’.

(emphases mine).

So it's not that they were the last ones to finish, but that they were the last ones to be started in the background.

다른 팁

This is from the bash man page:

In output pertaining to jobs (e.g., the output of the jobs command), the current job is always flagged with a +, and the previous job with a -.

So basically + behind the [17] is because it was the last job started and the - behind [16] is because that was the previous job.

From the bash manpage:

JOB CONTROL ...

When bash starts  a  job
   asynchronously (in the background), it prints a line that looks like:

          [1] 25647 

...

The previous job may be referenced using %-. In output pertaining to jobs (e.g., the output of the jobs command), the current job is always flagged with a +, and the previous job with a -. A single % (with no accompanying job specification) also refers to the current job.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top