-
-/**
-Starts the external program. Fill in argv before calling this.
-*/
-void ExternalAction::launch()
-{
- if(builder.get_verbose()>=2)
- {
- for(StringList::const_iterator i=argv.begin(); i!=argv.end(); ++i)
- {
- if(i!=argv.begin())
- cout<<' ';
- cout<<*i;
- }
- cout<<'\n';
- }
-
- if(builder.get_dry_run())
- pid=-1;
- else
- {
- pid=fork();
- if(pid==0)
- {
- char *argv_[argv.size()+1];
- for(CountingIterator<string, StringList::iterator> i=argv.begin(); i!=argv.end(); ++i)
- argv_[i.count()]=strdup(i->c_str());
- argv_[argv.size()]=0;
- execvp(argv_[0], argv_);
- cout<<"Couldn't execute "<<argv.front()<<'\n';
- exit(1);
- }
- else if(pid<0)
- pid=0;
- }
-}