开发者

System call return value in C

开发者 https://www.devze.com 2022-12-20 08:32 出处:网络
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 execute

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

精彩评论

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

关注公众号