fork download
  1. #include <iostream>
  2. #include<unistd.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. pid_t x;
  7. x=fork();
  8. if(x==0)
  9. {
  10. std::cout<<"in child"<<std::endl;
  11. execlp("pwd", "pwd", NULL);
  12. }
  13. else
  14. {
  15. std::cout<<"in parent"<<std::endl;
  16. }
  17. std::cout<<"bye"<<std::endl;
  18. return 0;
  19. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
in parent
bye
in child