B
bill
Does the following constitute a memory leak?
int
main(int ac, char **av)
{
char *buf;
while(1) {
buf = malloc(BIG_NUMBER);
execv(av[0], av);
}}
The question is motivated by the following scenario:
I am using a 3rd party kernel module that I really do
not trust, and it exhibits strange behavior when I use
their free functions. Rather than trying to figure out
the proper usage of their library
and do things like
while(1) {
do_stuff(); /* should only return on error*/
clean_up();
}
I was thinking of replacing clean_up() with
an exec call. (Currently, the loop gets into
a state that is clearly unhappy, and killing the process
and restarting a new instance works to resolve
the errors). Would replacing clean_up() with execv() be
equivalent to killing the process and restarting
a new instance? or will I just be masking a bigger
problem? Clearly, the correct solution is to stop
using this kernel module, but that is unfortunately
out of my hands.
int
main(int ac, char **av)
{
char *buf;
while(1) {
buf = malloc(BIG_NUMBER);
execv(av[0], av);
}}
The question is motivated by the following scenario:
I am using a 3rd party kernel module that I really do
not trust, and it exhibits strange behavior when I use
their free functions. Rather than trying to figure out
the proper usage of their library
and do things like
while(1) {
do_stuff(); /* should only return on error*/
clean_up();
}
I was thinking of replacing clean_up() with
an exec call. (Currently, the loop gets into
a state that is clearly unhappy, and killing the process
and restarting a new instance works to resolve
the errors). Would replacing clean_up() with execv() be
equivalent to killing the process and restarting
a new instance? or will I just be masking a bigger
problem? Clearly, the correct solution is to stop
using this kernel module, but that is unfortunately
out of my hands.