X-Git-Url: https://git.saurik.com/apple/dyld.git/blobdiff_plain/dd1e3476105179eb3efd5ebd2af97f6de91170b3..16b475fcb248267b8b51f759bc62a49ec2afa88d:/testing/nocr/nocr.cpp?ds=inline diff --git a/testing/nocr/nocr.cpp b/testing/nocr/nocr.cpp new file mode 100644 index 0000000..dd08d40 --- /dev/null +++ b/testing/nocr/nocr.cpp @@ -0,0 +1,35 @@ +#include +#include +#include +#include +#include + +#include "test_support.h" + +extern const char** environ; + +int main(int argc, const char* argv[], const char* envp[], const char* apple[]) { + if ( argc < 2 ) { + fprintf(stderr, "usage: nocr prog args...\n"); + return EXIT_FAILURE; + } + + _process process; + process.set_executable_path(argv[1]); + process.set_args(&argv[2]); + process.set_env(environ); + process.set_crash_handler(^(task_t task) { + exit(0); + }); + process.set_exit_handler(^(pid_t pid) { + int status = 0; + (void)waitpid(pid, &status, 0); + + // Only call exit if the child exited normally, otherwise keep running to consume the crash + if (WIFEXITED(status)) { + exit(0); + } + }); + process.launch(); + dispatch_main(); +}