c++ - POSIX_SPAWN Faliure -


#include<iostream> #include<spawn.h> #include<stdlib.h> #include<sys/wait.h> using namespace std;  int main(int argc,char *argv[],char *envp[]) { pid_t c1,c2; int ret1,ret2,val; ret1=posix_spawn(&c1,"t.cpp",null,null,argv,envp); ret2=posix_spawn(&c2,"t.cpp",null,null,argv,envp); wait(&val); wait(&val); cout<<"\n\nchild process 1: "<<c1; cout<<"\n\nchild process 2: "<<c2; cout<<"\n\n"<<ret1; cout<<"\n\n"<<ret2<<"\n"; } 

above code creates 2 child processes , each process in supposed execute t.cpp simple hello world code in c++. doesnt execute it. in fact code works without creating t.cpp. can explain why happening , how execute t1.cpp?

this way of creating new process:

posix_spawn(&pid,"my_exe",null,null,argv,envp);

where my_exe executable file created after build program. in case t executable created after build program.


Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -