add sigaction handler to Example Browser, to always shutdown shared memory
make GUI_SERVER more reliable next attempt to connect to SHARED_MEMORY in Gym envs, if available, before DIRECT/GUI allow software rendering fallback, even if ER_BULLET_HARDWARE_OPENGL is chosen in getCameraImage
This commit is contained in:
@@ -20,8 +20,51 @@
|
||||
static double gMinUpdateTimeMicroSecs = 1000.;
|
||||
|
||||
|
||||
static bool interrupted=false;
|
||||
static OpenGLExampleBrowser* sExampleBrowser=0;
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <signal.h>
|
||||
#include <err.h>
|
||||
#include <unistd.h>
|
||||
static void cleanup(int signo)
|
||||
{
|
||||
printf("SIG cleanup: %d\n", signo);
|
||||
|
||||
if (interrupted) { // this is the second time, we're hanging somewhere
|
||||
// if (example) {
|
||||
// example->abort();
|
||||
// }
|
||||
|
||||
b3Printf("Aborting and deleting SharedMemoryCommon object");
|
||||
sleep(1);
|
||||
delete sExampleBrowser;
|
||||
sExampleBrowser = 0;
|
||||
errx(EXIT_FAILURE, "aborted example on signal %d", signo);
|
||||
} else
|
||||
{
|
||||
b3Printf("no action");
|
||||
}
|
||||
interrupted = true;
|
||||
warnx("caught signal %d", signo);
|
||||
}
|
||||
#endif//_WIN32
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
#ifndef _WIN32
|
||||
struct sigaction action;
|
||||
memset(&action, 0x0, sizeof(action));
|
||||
action.sa_handler = cleanup;
|
||||
static const int signos[] = { SIGHUP, SIGINT, SIGQUIT, SIGABRT, SIGSEGV, SIGPIPE, SIGTERM };
|
||||
for (int ii(0); ii < sizeof(signos) / sizeof(*signos); ++ii) {
|
||||
if (0 != sigaction(signos[ii], &action, NULL)) {
|
||||
err(EXIT_FAILURE, "signal %d", signos[ii]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
b3CommandLineArgs args(argc, argv);
|
||||
b3Clock clock;
|
||||
@@ -31,6 +74,7 @@ int main(int argc, char* argv[])
|
||||
examples.initExampleEntries();
|
||||
|
||||
OpenGLExampleBrowser* exampleBrowser = new OpenGLExampleBrowser(&examples);
|
||||
sExampleBrowser = exampleBrowser;//for <CTRL-C> etc, cleanup shared memory
|
||||
bool init = exampleBrowser->init(argc, argv);
|
||||
exampleBrowser->registerFileImporter(".urdf", ImportURDFCreateFunc);
|
||||
exampleBrowser->registerFileImporter(".sdf", ImportSDFCreateFunc);
|
||||
@@ -57,7 +101,7 @@ int main(int argc, char* argv[])
|
||||
clock.reset();
|
||||
exampleBrowser->update(deltaTimeInSeconds);
|
||||
}
|
||||
} while (!exampleBrowser->requestedExit());
|
||||
} while (!exampleBrowser->requestedExit() && !interrupted);
|
||||
}
|
||||
delete exampleBrowser;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user