OK, it has nothing to do with embedded programming. I'd use the same types of things to create a serial terminal for talking with a console or GUI that I was developing.
In this example I'll use gcalctool (calculator) but you can substitute any command that leaves something running that you don't care if all instances are stopped (killed).
To understand what I'm talking about try the following,
First to show what I'm trying to do, execute these at the command line
setsid gcalctool
setsid gcalctool
killall gcalctool
It should bring up two calculators and then kill them when you execute the "killall" command
Now for the CodeBlocks changes, I'm assuming I don't have to tell you every keypress.
Create a new tool "Calc"
Put
setsid in the executable entry and
gcalctool in the parameters entry.
Set it for the fourth launching option (visible and detached).
Add another tool "Kill Calc"
Put
killall in the executable entry and
gcalctool in the parameters entry.
Set it for the fourth launching option (visible and detached).
Exit the tools configuration setup
Start a couple of calcs using the tool entry
Use the Kill Calc tool entry to kill them all.
Open a project
Open the properties of the project
Go to the debugger tab
In the
Remote debugging support area at the bottom go to the tab for
Additional shell commandsIn the
Before connection area, enter "killall gcalctool"
According to the tip in this area these will be executed whether there is a remote connection or not.
Save the changes and exit the
Project/target optionsThis project should now be setup so that every time you start the debugger the "killall gcalctool" command would be run before starting the gdb session.
Start a couple of session of gcalctool using the
Tools menu
Start debugging the project
The calculators should disappear (get killed) when the
killall line is executed
They don't.
Anything more you need?