Allow recognizing multiple DF SHM processes by the client

develop
Petr Mrázek 2010-03-08 01:54:46 +01:00
parent 958ca0e384
commit 90baaad19b
4 changed files with 11 additions and 9 deletions

@ -180,7 +180,7 @@ void Process::Private::DF_SyncAffinity( void )
#endif
}
Process::Process(vector <memory_info *> & known_versions)
Process::Process(uint32_t PID, vector< memory_info* >& known_versions)
: d(new Private())
{
char exe_link_name [256];
@ -232,7 +232,7 @@ Process::Process(vector <memory_info *> & known_versions)
/*
* get the PID from DF
*/
if(d->DF_GetPID(d->my_pid))
if(d->DF_GetPID(d->my_pid) && d->my_pid == PID)
{
// find its binary
sprintf(exe_link_name,"/proc/%d/exe", d->my_pid);

@ -66,7 +66,7 @@ namespace DFHack
Private *d;
public:
// this is the single most important destructor ever. ~px
Process(vector <memory_info *> & known_versions);
Process(uint32_t PID ,vector <memory_info *> & known_versions);
~Process();
// Set up stuff so we can read memory

@ -46,7 +46,7 @@ bool ProcessEnumerator::findProcessess()
{
DIR *dir_p;
struct dirent *dir_entry_p;
/*
Process *p = 0;
p = new Process(d->meminfo->meminfo);
if(p->isIdentified())
@ -58,7 +58,7 @@ bool ProcessEnumerator::findProcessess()
delete p;
p = 0;
}
/*
*/
// Open /proc/ directory
dir_p = opendir("/proc/");
// Reading /proc/ entries
@ -69,7 +69,7 @@ bool ProcessEnumerator::findProcessess()
{
continue;
}
Process *p2 = new NormalProcess(atoi(dir_entry_p->d_name),d->meminfo->meminfo);
Process *p2 = new Process(atoi(dir_entry_p->d_name),d->meminfo->meminfo);
if(p2->isIdentified())
{
d->processes.push_back(p2);
@ -79,6 +79,7 @@ bool ProcessEnumerator::findProcessess()
{
delete p2;
}
/*
Process *p3 = new WineProcess(atoi(dir_entry_p->d_name),d->meminfo->meminfo);
if(p3->isIdentified())
{
@ -89,9 +90,10 @@ bool ProcessEnumerator::findProcessess()
{
delete p3;
}
*/
}
closedir(dir_p);
*/
// return value depends on if we found some DF processes
if(d->processes.size())
{

@ -85,8 +85,8 @@ void SHM_Init ( void )
}
inited = true;
// name for the segment
key_t key = 123466;
// name for the segment, an accident waiting to happen
key_t key = SHM_KEY + OS_getPID();
// find previous segment, check if it's used by some processes.
// if it isn't, kill it with fire