So the Windows CreateProcess API has a flag called CREATE_NEW_CONSOLE, and while I've never really understood what that's useful for, as fate would have it, working on Linux now, that's exactly the kind of flag I am discovering I am needing!
Here's the scenario:
- Launching a console app from a GUI app
(the GUI app could be my own, or say, any File Manager on Linux)
- The window (console) never shows, and the app starts polling 100% of a CPU core
This scenario works properly when the original invocation is from a terminal window:
- Even if a GUI app is launched this way, when it launches the console app, its console output shows on the originally invoking terminal
So is there a way, in Lazarus of course, to check whether a running console app has a terminal window attached; and if not - to create one (ideally without having to relaunch the console app itself)?