What happens when I have the following situation:
class A: holds dynamically allocated object B. This will create and destroy them.
class B: has an execution function called A. Execution will be fork (), and the child will use execvp to start another process. BUT, the flag can be set so that the parent does not wait for the child (allows it to work in the background).
My question is: what does the plug do in this case? I know that the child has a full copy of the parent process, but I'm a bit confused. Does this mean that the child process has its own object A, which contains B? And what happens if B doesn't wait, but A deletes B?
Here is a sample code. Please note that this is simplified from what I'm actually doing.
class B; class A { public: void addAction( const std::string &name ) { _bq.push( new B( name ) ); } void doActions( bool wait = true ) { while ( !_bq.empty() ) { B* b = _bq.front(); b->execute( wait ); _bq.pop(); delete b; } } ~A() {
source share