I am using system function in C code to invoke cp command. I want to know whether it got executed 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.