Running an underground UNIX program from c++ code and then terminating it.

Hi all,
im designing a QT program in C++ that needs to interact with an underlying server software installed on my computer.
What i need to do is to have a QT window with two buttons: RUN and STOP

When i hit run, i want the program to fork and exec the server as a child process.
Then, when i want to restart this software i need to be able to click STOP and terminate the server, being able to restart it as many times as i want.

The server i will be controlling does not needs complicate initialization or arguments passing, i just need to start the "myserver" executable in the program path.

I would be able to do that with fork and exec but since i'm new to GUIs in general i'm not sure how to accomplish this task with the GUI events in mind.
How should i design this function to be able to catch the START and STOP event
from the button event actions?

This is want i want in order:
1) start the program with no childs
2) start the child process in background (without waiting for it to execute)
when i trigger the QT clicked() flag the start button
3) close the child process (and not the whole program) when i trigger the stop button

If you want to share code i would be grateful but i'm ok with just an explanation of the required program structure.
Thank you all for your help.
Last edited on
Man, you've been a great help.
That is exactly what i was looking for!
Topic archived. No new replies allowed.