'How to create a terminal process/thread and create child threads with in that terminal thread in ruby?

I'm trying to launch a terminal process and source some scripts within the terminal thread and then launch multiple threads which run in this terminal thread. Ideally what I'm trying to achieve here is from a ruby script I should be able to open a process/thread which emulates a terminal and source some scripts that setup env variables and load modules which are required for running the commands in child threads and using this single emulated terminal I should be able to launch forked threads with commands. I can spawn a terminal for each child thread to source the scripts but when this happens in parallel it will raise an issue, so I should be able to avoid that. how can I achieve this in ruby?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source