0

With reference to wait for two PID in c-shell

In

while ( `ps -p "$pid1,$pid2" | wc -l` > 1 )
  sleep 1
end

what is the expression ps -p "$pid1,$pid2" | wc -l > 1 doing?

andreee
  • 4,459
  • 22
  • 42
Manish
  • 33
  • 3

1 Answers1

0

It simply checks if there are any processes matching at least one of the given pid1 or pid2.

Just do your own quick check with PIDs 1 and 2:

  $ ps -p "1,2" # Show all processes with PID=1 and PID=2
  PID TTY          TIME CMD
    1 ?        00:00:57 systemd
    2 ?        00:00:00 kthreadd

The output has three lines, as a pipe to wc -l will also tell you. So as long as you have more than a line (the header is always there), your loop will be executed.

andreee
  • 4,459
  • 22
  • 42