|
From: Tom H. <to...@co...> - 2009-01-19 08:52:51
|
Nicholas Nethercote wrote:
> int main(int argc, char **argv)
> {
> if (argc == 1)
> {
> if (execve(argv[0], NULL, NULL) < 0)
> {
> perror("execve");
> exit(1);
> }
> }
>
> exit(0);
> }
> --------------------------------
>
> Any ideas what this is meant to demonstrate? I don't even understand
> it, it looks to me like it should go into an infinite loop, just
> repeatedly execve'ing itself. Any explanations are welcome...
It only exec's itself once, as that exec doesn't pass any arguments so
the second time round argc will be zero and it won't do the exec.
I suspect it is checking that we handle a NULL argv pointer to execve
correctly - presumably at some point we complained about it.
Tom
--
Tom Hughes (to...@co...)
http://www.compton.nu/
|