Sometimes I start several processes by using another script (in my case Ruby). I call this script from a terminal running bash. I would like to start those processes in the script in the background (by using &). Unfortunately those processes are not listed when calling jobs from within the terminal that run the script. I guess because those are run in a sub shell. This makes it hard to manage them.

Is there a way so that those processes are available by using jobs in the parent shell?

link|improve this question

75% accept rate
I wonder if ptree $$ would show you ruby's jobs from the parent shell. – glenn jackman Apr 25 '11 at 20:20
ptree does not seem to be available on my system. Ubuntu recommends me to install adacontrol. – Zardoz Apr 25 '11 at 20:28
feedback

1 Answer

up vote 1 down vote accepted

The only way is for the jobs themselves to be started in the parent shell.

At the moment you have:

shell -> ruby -> shell -> command

If you could have the commands in a shell script, and not ruby, you could execute that shell script in the current shell with

$ source myfile.sh

or short-hand:

$ . myfile.sh

Then any programs started in the background in that script should be in jobs in the current shell.

link|improve this answer
Bye bye ruby ... hello bash programming ... brrrrrr ;-) – Zardoz Apr 25 '11 at 19:46
feedback

Your Answer

 
or
required, but never shown

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