3949 signal (tp, sig) { register struct proc *p; for (p=proc;p<&proc[NPROC];p++) if (p->p ttyp == tp) psignal (p,sig); }
In this example of the “for” statement, the pointer variable “p” is stepped through each element of the array “proc” in turn.
Actually the original code had
for (p=&proc[0];p<&proc[NPROC];p++)
but it wouldn’t fit on the line! As noted earlier, the use of “proc” as an alternative to the expression “&proc[0]” is acceptable in this context.
This kind of “for” statement is almost a cliche in UNIX so you had better learn to recognise it. Read it as
for p = each process in turn
Note that “proc[NPROC]” is the address of the (NPROC+1)-th element of the array (which does not of course exist) i.e. it is the first location beyond the end of the array.
At the risk of overkill we would point out again that whereas in the previous example
i++;
meant add one to the integer “i”, here
p++;
means “skip p to point to the next structure”.