diff --git a/renderdoccmd/renderdoccmd.cpp b/renderdoccmd/renderdoccmd.cpp index 5ad5ee79f..ea7350a6d 100644 --- a/renderdoccmd/renderdoccmd.cpp +++ b/renderdoccmd/renderdoccmd.cpp @@ -31,6 +31,9 @@ using std::string; using std::wstring; +bool usingKillSignal = false; +volatile uint32_t killSignal = false; + void readCapOpts(const std::string &str, CaptureOptions *opts) { if(str.length() < sizeof(CaptureOptions)) @@ -403,12 +406,15 @@ struct ReplayHostCommand : public Command string host = parser.get("host"); uint32_t port = parser.get("port"); - volatile bool32 kill = false; - std::cerr << "Spawning a replay host listening on " << (host.empty() ? "*" : host) << ":" << port << "..." << std::endl; - RENDERDOC_SpawnReplayHost(host.empty() ? NULL : host.c_str(), port, &kill); + usingKillSignal = true; + + RENDERDOC_SpawnReplayHost(host.empty() ? NULL : host.c_str(), port, &killSignal); + + std::cerr << std::endl << "Cleaning up from replay hosting." << std::endl; + return 0; } }; @@ -449,6 +455,9 @@ struct ReplayCommand : public Command if(parser.exist("remote-host")) { + std::cout << "Replaying '" << filename << "' on " << parser.get("remote-host") << ":" + << parser.get("remote-port") << "." << std::endl; + ReplayCreateStatus status = RENDERDOC_CreateRemoteReplayConnection( parser.get("remote-host").c_str(), parser.get("remote-port"), &remote); @@ -476,6 +485,8 @@ struct ReplayCommand : public Command } else { + std::cout << "Replaying '" << filename << "' locally.." << std::endl; + ReplayCreateStatus status = RENDERDOC_CreateReplayRenderer(filename.c_str(), &progress, &renderer); diff --git a/renderdoccmd/renderdoccmd.h b/renderdoccmd/renderdoccmd.h index c8f926c0a..2214cf502 100644 --- a/renderdoccmd/renderdoccmd.h +++ b/renderdoccmd/renderdoccmd.h @@ -47,6 +47,9 @@ struct Command virtual bool IsCaptureCommand() = 0; }; +extern bool usingKillSignal; +extern volatile uint32_t killSignal; + void add_command(const std::string &name, Command *cmd); void add_alias(const std::string &alias, const std::string &command); diff --git a/renderdoccmd/renderdoccmd_linux.cpp b/renderdoccmd/renderdoccmd_linux.cpp index ea98154d5..f389039d4 100644 --- a/renderdoccmd/renderdoccmd_linux.cpp +++ b/renderdoccmd/renderdoccmd_linux.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -134,6 +135,14 @@ void DisplayRendererPreview(ReplayRenderer *renderer, TextureDisplay &displayCfg // be resolved and libGL wouldn't link, meaning dlsym(RTLD_NEXT) would fai extern "C" void glXWaitGL(); +void sig_handler(int signo) +{ + if(usingKillSignal) + killSignal = true; + else + exit(1); +} + int main(int argc, char *argv[]) { std::setlocale(LC_CTYPE, ""); @@ -142,6 +151,8 @@ int main(int argc, char *argv[]) if(never_run) glXWaitGL(); + signal(SIGINT, sig_handler); + // do any linux-specific setup here // process any linux-specific arguments here