Parralell running child process.

Hello,
I am new to c++. I want to create a child process programmatically. I searched the web. and see that i can use fork() and exec() but. I want the to run the parent process and the child process parallel. Also i want to kill the child process if necessary, and get the information when the child finished its job. At the child side i want to synchronize two folders with rsych.
> i can use fork() and exec() but. I want the to run the parent process and the child process parallel.
So, ¿what's the problem?
Also, ¿what should the parent process do?

fork() gives the child pid, so you can send it signals (with kill())
the parent receives SIGCHLD when the child stops or terminates
Whe you use fork(), the parent and child do run concurrently.

Why do you want to kill the child?

When th child terminates, you can get it's return value using waitpid(). As the child inherits the parent's file handles, you can use them to communicate with the child using it's stdin/stdout.

The child can do whatever you like. But if all you want to do is run rsync with different args, just let the parent run them both and wait for them to complete.
Topic archived. No new replies allowed.