How to get the return value of a program ran via calling a member of the exec family of functions?

后端 未结 5 2081
面向向阳花
面向向阳花 2020-11-27 06:45

I know that it is possible to read commands output with a pipe? But what about getting return value ? For example i want to execute:

execl(\"/bin/ping\", \"/         


        
5条回答
  •  一个人的身影
    2020-11-27 07:44

    You can use waitpid to get the exit status of you child process as:

    int childExitStatus;
    waitpid( pID, &childExitStatus, 0); // where pID is the process ID of the child.
    

提交回复
热议问题