1
26: execve(prog[0],prog,env);
27: return 0; 


execve() does not return on success, and  the  text,  data,  bss,  and
       stack  of  the  calling process are overwritten by that of the program
       loaded.

return 0;为了什么?

4

2 回答 2

1

我建议停止这个编译器警告。

$ cat | gcc -W -Wall -x c -
int main(){}
^D
<stdin>: In function 'main':
<stdin>:1:1: warning: control reaches end of non-void function

这也将使静态分析器和 IDE 对同一事物发出快乐的警告。

于 2011-04-16T21:12:39.707 回答
0

那条线以防万一execve()失败并返回。从理论上讲,它永远不应该发生,但有时会发生。通常,返回值设置为某个随机数以表示存在错误。

于 2019-02-13T13:12:34.050 回答