Re: evecv/memory leak



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

John Reiser <jreiser@xxxxxxxxxxxx> writes:

> bill pursell wrote:
>
>> int
>> main(int ac, char **av)
>> {
>> process_stuff();
>> execv(av[0],av);
>> }
>>
>> The question is: is this identical to killing the process and
>> restarting?
>
> No. process_stuff() can open more file descriptors each time,
> change the current directory, etc., and mere execv() does
> not "reset" those. But execve() does reset the address space.

Another consideration is that if process_stuf() returns on error very
frequently, you don't want to be calling exec() in an infinite loop.
Adding some logic to make sure you don't exec e.g. more than five
times a minute might be a good idea. You might do this my having a
parent process that forks a child and then waits for it, respawning
when required, and this can do the necessary rate limiting. This is
similar to init and spawning getty.


Regards,
Roger

- --
Roger Leigh
Printing on GNU/Linux? http://gimp-print.sourceforge.net/
Debian GNU/Linux http://www.debian.org/
GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8+ <http://mailcrypt.sourceforge.net/>

iD8DBQFDsdatVcFcaSW/uEgRArYCAKC80TaI0rOGhbdPYBc73yT1a+nfOwCgjaeF
9+DQFAzv9xnHE1n5yi9ebgs=
=1Hmf
-----END PGP SIGNATURE-----
.