1

I have a call to an external program that opens a "modal" window, since it's in the same thread as the main loop it blocks redrawing of the underlying window.

The program runs as a separate process and I am communicating with the program via pipes.

From what I've read it's bad practice to have an additional main loop, so what is the correct way to avoid this lockup?

The question is how to make a separate thread in my own program to do the communication with that program without blocking the entire main loop.

Didi Kohen
  • 560
  • 4
  • 19
  • 1
    Start a new process for the external program? – Some programmer dude Jun 28 '15 at 13:08
  • It is in a new process, I need to communicate with it via pipes. – Didi Kohen Jun 28 '15 at 13:10
  • The problem is if you have opened a window in one thread, and manipulating it directly in another thread. If you truly uses multiple processes then it's okay because those are totally separated. And please update your tags to reflect the very major change in the question from threads to processes. – Some programmer dude Jun 28 '15 at 13:12

1 Answers1

1

Use a non blocking API to run the external program, such as GSubprocess https://developer.gnome.org/gio/stable/GSubprocess.html or the lower level spawn API https://developer.gnome.org/glib/stable/glib-Spawning-Processes.html

You could also use a thread but the above APIs are much easier.

You have to somehow return control to the main loop while the subprocess runs, that's the bottom line.

Havoc P
  • 8,365
  • 1
  • 31
  • 46