Calling external Executable with CubitProcess() without freezing Cubit

Hi,
i wanted to use CubitProcess() to call an external executable with command line arguments. Basically i want to push an input file to a solver, catch the output from the solver when there is one and i want to know when the solver has exited. The solver should run independent from cubit so one can still work with cubit.

If i use CubitProcess() with wait() i end up freezing cubit until the solver exits.
If i try to use read_output_channel() in a loop to catch the output from the executable i only end up creating myself a loop that freezes the gui again.

I would be happy about some ideas to get this done.

thanks,
norbert

The read_output_channel method has a timeout parameter. The default (-1) will end up waiting forever. If you add a timeout value the call to read_output_channel will not block forever. However, if you have it in a loop, even with a small timeout, you will effectively block cubit forever since cubit is a single thread process. You couldn’t even put the loop on a separate thread because there would be no safe way to re-enter cubit.

If you’re using Qt, you should be able to use a QTimer to check periodically for output from the other process.

1 Like

Thanks a lot! QTimer does the trick!

On Centos 7 my childprocess can´t create and access files with my desired executable. With gedit it works. Starting my exec from the terminal also works. On Ubuntu my executable also works as intendet.

Do you maybe know how to fix this on Centos? Changing the owner of my exec to root or give write access for everyone in my working directory hasn´t changed anything.