fix attach/detach

develop
Petr Mrázek 2010-01-01 22:19:09 +00:00
parent 037d1369cb
commit 84c68fb31c
2 changed files with 15 additions and 6 deletions

@ -393,7 +393,7 @@ bool SHMProcess::resume()
bool SHMProcess::attach() bool SHMProcess::attach()
{ {
int status; int status;
if(g_pProcess != NULL) if(g_pProcess != 0)
{ {
cerr << "there's already a different process attached" << endl; cerr << "there's already a different process attached" << endl;
return false; return false;
@ -412,6 +412,7 @@ bool SHMProcess::attach()
} }
d->attached = false; d->attached = false;
cerr << "unable to suspend" << endl; cerr << "unable to suspend" << endl;
// FIXME: detach sehment here
return false; return false;
} }
cerr << "unable to attach" << endl; cerr << "unable to attach" << endl;
@ -428,10 +429,18 @@ bool SHMProcess::detach()
{ {
resume(); resume();
} }
// detach segment
if(shmdt(d->my_shm) != -1)
{
d->attached = false; d->attached = false;
d->suspended = false; d->suspended = false;
g_pProcess = 0;
return true; return true;
} }
// fail if we can't detach
perror("failed to detach shared segment");
return false;
}
// FIXME: use recursion // FIXME: use recursion