I have a script foo which, if provided an argument start, starts, among other things a script bar in the background and exits - bar contains an infinite loop. At a later stage, I want to call foo  with argument stop and I would like that script bar, which still runs in the background stops running. What is the text book way of achieving this?
Terminating a shell script bar from a script foo.
shell script;kill;background process
To do this the way init scripts normally do, when foo starts bar, you should write the PID of bar to a file named /var/run/bar (or similar location depending on your OS). Then when you call foo stop, you read the PID and signal the bar process appropriately. Of course there are other solutions, but this seems to be a textbook answer.