Skip to content

Commit

Permalink
Add r2 -Q for faster quits
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Mar 20, 2017
1 parent 295cd01 commit ca0c490
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
19 changes: 16 additions & 3 deletions binr/radare2/radare2.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,8 @@ int main(int argc, char **argv, char **envp) {
const char *forcebin = NULL;
const char *asmbits = NULL;
ut64 mapaddr = 0LL;
int quiet = false;
bool quiet = false;
bool quietLeak = false;
int is_gdb = false;
const char * s_seek = NULL;
RList *cmds = r_list_new ();
Expand Down Expand Up @@ -488,7 +489,7 @@ int main(int argc, char **argv, char **envp) {
return 0;
}

while ((c = getopt (argc, argv, "=02AMCwfF:H:hm:e:nk:Ndqs:p:b:B:a:Lui:I:l:P:R:c:D:vVSzu"
while ((c = getopt (argc, argv, "=02AMCwfF:H:hm:e:nk:NdqQs:p:b:B:a:Lui:I:l:P:R:c:D:vVSzu"
#if USE_THREADS
"t"
#endif
Expand Down Expand Up @@ -605,6 +606,10 @@ int main(int argc, char **argv, char **envp) {
case 'P':
patchfile = optarg;
break;
case 'Q':
quiet = true;
quietLeak = true;
break;
case 'q':
r_config_set (r.config, "scr.interactive", "false");
r_config_set (r.config, "scr.prompt", "false");
Expand Down Expand Up @@ -673,6 +678,9 @@ int main(int argc, char **argv, char **envp) {
r_core_loadlibs (&r, R_CORE_LOADLIBS_ALL, NULL);
}
run_commands (cmds, files, quiet);
if (quietLeak) {
exit (0);
}
r_io_plugin_list (r.io);
r_cons_flush ();
r_list_free (evals);
Expand Down Expand Up @@ -1180,8 +1188,9 @@ int main(int argc, char **argv, char **envp) {
}
if (lock) r_th_lock_enter (lock);
/* -1 means invalid command, -2 means quit prompt loop */
if ((ret = r_core_prompt_exec (&r)) == -2)
if ((ret = r_core_prompt_exec (&r)) == -2) {
break;
}
if (lock) r_th_lock_leave (lock);
if (rabin_th && !r_th_wait_async (rabin_th)) {
eprintf ("rabin thread end \n");
Expand Down Expand Up @@ -1254,6 +1263,10 @@ int main(int argc, char **argv, char **envp) {
ret = r.num->value;

beach:
if (quietLeak) {
exit (ret);
return ret;
}
// not really needed, cause r_core_fini will close the file
// and this fh may be come stale during the command
// exectution.
Expand Down
4 changes: 3 additions & 1 deletion man/radare2.1
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ Only load the rbin structures (elf, mach0, ...)
.It Fl N
Do not load user settings/projects from ~/.radare2rc, ~/.config/radare2/radare2rc and the scripts inside .../radare2rc.d/ directory.
.It Fl q
Quiet mode (no prompt)
Quiet mode (no prompt) and quit after running the commands specified with -i or -c
.It Fl Q
Same as q, but exiting without freeing RCore, this produces leaks at exit time, but saves some precious ms to run the testsuite in fast mode.
.It Fl p Ar prj
Set project file
.It Fl P Ar file
Expand Down
1 change: 1 addition & 0 deletions sys/cherrypull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ git branch -D branch
if [ -d t/overlay ]; then
make -C t apply
git commit -a
# git reset --hard @^^
fi

0 comments on commit ca0c490

Please sign in to comment.