4

In linux shell script i have

vlc /some/file/path.mkv &
wait

Now until my background process return wait call will be blocked. But here i want that until my background process return i want to execute one loop and in that print some data continuous. So when ever my background process return/exit i need to break that loop.

How to do that in shell script?

Jeegar Patel
  • 26,264
  • 51
  • 149
  • 222
  • Possible duplicate of [How to wait in bash for several subprocesses to finish and return exit code !=0 when any subprocess ends with code !=0?](http://stackoverflow.com/questions/356100/how-to-wait-in-bash-for-several-subprocesses-to-finish-and-return-exit-code-0) – Srini V Jul 05 '16 at 09:37
  • @realspirituals Sir it looks like my question and its different – Jeegar Patel Jul 05 '16 at 09:41

1 Answers1

8

See if this works for you

vlc /some/file/path.mkv &
while [[ -n $(jobs -r) ]]; do echo -n "some data"; sleep 1; done

jobs -r checks running processes, and printing something, the script stops when your vlc process is done.

Srini V
  • 11,045
  • 14
  • 66
  • 89