Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The script I'm writing launches process A, which after an uncertain amount of time, launches a child process B.

I need the script to execute a command C which depends on process B. But B might not be there at call time!

How to wait until a process with a certain given name is spawned?

I reckon I could just blindly poll/wait inside an infinite loop but maybe there's a fancier solution...

share|improve this question
up vote 3 down vote accepted

Does C run parallel to B, or after B? (series?)

If parallel, why not have B start C at same time (via a script?)

If series, then modify script A to add C after B.

share|improve this answer
Clever approach, I didn't think of wrapping commands -potentially not user-modificable, e.g. firefox- in scripts. – vemv Jul 6 '12 at 12:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.