man system可以看到如下返回值说明
The value returned is -1 on error (e.g. fork(2) failed), and the return status of the command otherwise. This latter return
status is in the format specified in wait(2). Thus, the exit code of the command will be WEXITSTATUS(status). In case /bin/sh
could not be executed, the exit status will be that of a command that does exit(127).
If the value of command is NULL, system() returns nonzero if the shell is available, and zero if not.
system() does not affect the wait status of any other children.<strong>
system是个综合的操作,分解开来看就是相当于执行了
1.fork 生成一个子进程。
2.在子进程执行 execl("/bin/sh","sh","-c" command,(char*)0);
3.waitpid<strong>
system函数对返回值的处理分3个阶段
阶段一:创建子进程等准备工作,失败返回-1
阶段二: