c++ - execlp hanging after execution -


i'm calling external binary (webots simulator) in cpp program, calling fork() , execlp(), takes on argument path of specific file. there no issues when path file valid , file exists, however, when point invalid file, expected could not open file: 'file.wbt' but child process not exit. though might due webot's internal code , how handles such errors, however, if call webots file.wbt on system's bash shell same error gets thrown but process ends should.

a compilable section of program:

#include <iostream> #include <fstream> #include <stdio.h>  #include <sys/types.h> #include <signal.h>  int start_webots(const char* world){     //starting webots child process known pid     int pid = fork();     if (pid == 0){         printf("starting webots...");         execlp("/usr/bin/webots","webots",world,null);         printf("finished executing webots");         exit(1);     }     else printf("webots pid: %i\n", pid);     return pid; }  int main(int argc, char const *argv[]){     int pid=start_webots("/home/joao/work/asbg/code/cpp/darwin/worlds/darwin_cpgs_noise.webt");      if (kill(pid,0)) printf("no process running\n");     return 0; } 

the code lines after execlp naturally never executed long binary exists (webots installed), since webots replaces child process. however, after error could not open (...) don't ouput stdout, program hangs, , processs webots running in background.

what doing wrong/how can find workaround or solution?


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -