Debugger and Destructor

Hi,

I am calling a destructor because I want to replace a duplicate branch and free the memory in a C++ program. In the program I did not use placement new but the rogram was getting hang when I tried to debug it so I tried reprogram it using fork() function along with exec() but it still is not working. should i use another debugger as I am using Visual c++ 2008 express edition or code warrior.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
pid_t pid = fork();

if (pid == 0) // now running in child process

{
    // The stuff that I wrote above (culminating in exec() )

    exec( /* whatever */ );

    // If control reaches here, exec() failed.

}

else if (pid != (-1)) // still in parent process

{

    // Carry on with the 'parent' process

}

else // fork() failed

{

     // Generate some kind of error condition

}
You kinda trailed off there, didn't you?

If you didn't use new to allocate the memory it's likely that using delete to deallocate it is what's causing the crash.

Also, is VC++ really letting you call fork()? That's a bit odd.
you dont need to use a different debugger

just make sure that do not try to allocate resource in one thread of execution and deallocate in other some time it can cause problems, and avoid exec() call inside the child thread(it tries to duplicate the child process and it might creat undefined problems)
Topic archived. No new replies allowed.