开发者

System call return value in C

I am using system function in C code to invoke cp command. I want to know whether it got execut开发者_如何学Pythoned successfully or not?


Use system() function. It returns the status of command executed. If this is 0, then it would seem this is successfull.


Should be enought to check the return value of system call.

From man system on Mac:

The system() function returns the exit status of the shell as returned by waitpid(2), or -1 if an error occurred when invoking fork(2) or waitpid(2). A return value of 127 means the execution of the shell failed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜