2009-11-16 20:19:13 -07:00
|
|
|
// Test suspend/resume
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <climits>
|
|
|
|
#include <vector>
|
|
|
|
#include <ctime>
|
|
|
|
#include <string>
|
|
|
|
using namespace std;
|
|
|
|
|
2010-05-25 22:48:23 -06:00
|
|
|
#include <DFHack.h>
|
2009-11-16 20:19:13 -07:00
|
|
|
int main (void)
|
|
|
|
{
|
|
|
|
string blah;
|
2010-05-23 15:06:10 -06:00
|
|
|
DFHack::ContextManager DFMgr("Memory.xml");
|
|
|
|
DFHack::Context * DF;
|
2010-03-26 06:01:46 -06:00
|
|
|
try
|
2009-11-16 20:19:13 -07:00
|
|
|
{
|
2010-05-23 15:06:10 -06:00
|
|
|
DF = DFMgr.getSingleContext();
|
|
|
|
DF->Attach();
|
2010-03-26 06:01:46 -06:00
|
|
|
}
|
|
|
|
catch (exception& e)
|
|
|
|
{
|
|
|
|
cerr << e.what() << endl;
|
|
|
|
#ifndef LINUX_BUILD
|
|
|
|
cin.ignore();
|
|
|
|
#endif
|
2009-11-16 20:19:13 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
cout << "Attached, DF should be suspended now" << endl;
|
|
|
|
getline(cin, blah);
|
|
|
|
|
2010-05-23 15:06:10 -06:00
|
|
|
DF->Resume();
|
2009-11-16 20:19:13 -07:00
|
|
|
cout << "Resumed, DF should be running" << endl;
|
|
|
|
getline(cin, blah);
|
|
|
|
|
2010-05-23 15:06:10 -06:00
|
|
|
DF->Suspend();
|
2009-11-16 20:19:13 -07:00
|
|
|
cout << "Suspended, DF should be suspended now" << endl;
|
|
|
|
getline(cin, blah);
|
|
|
|
|
2010-05-23 15:06:10 -06:00
|
|
|
DF->Resume();
|
2010-01-01 19:25:21 -07:00
|
|
|
cout << "Resumed, testing ForceResume. Suspend using SysInternals Process Explorer" << endl;
|
|
|
|
getline(cin, blah);
|
2009-11-18 18:48:18 -07:00
|
|
|
|
2010-05-23 15:06:10 -06:00
|
|
|
DF->ForceResume();
|
2010-01-01 19:25:21 -07:00
|
|
|
cout << "ForceResumed. DF should be running." << endl;
|
|
|
|
getline(cin, blah);
|
2009-11-18 18:48:18 -07:00
|
|
|
|
2010-05-23 15:06:10 -06:00
|
|
|
if(!DF->Detach())
|
2009-11-16 20:19:13 -07:00
|
|
|
{
|
|
|
|
cerr << "Can't detach from DF" << endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
cout << "Detached, DF should be running again" << endl;
|
|
|
|
getline(cin, blah);
|
|
|
|
|
|
|
|
return 0;
|
2010-01-01 19:25:21 -07:00
|
|
|
}
|