radareorg / radare2-r2pipe

Access radare2 via pipe from any programming language!
390 stars 99 forks source link

r2pipe.go: do not use `q!` because of the -1 exit code #125

Closed XVilka closed 3 years ago

XVilka commented 3 years ago

Currently if radare2 executes q! it returns -1 exit code which masks the possible errors when r2pipe.go used. Changing to q will ensure that exit code is 0 in case of success.

davendu commented 3 years ago

Maybe we may need Pipe.Close() for q and Pipe.Kill() for q!? And return error when Pipe.Close() if q does not shutdown the process. Is Pipe going to hold the child process in its control, or only act as a pipe? If the process is holding by Pipe it might be necessary to it.

fangxlmr commented 3 years ago

@davendu

Pipe.Kill() is a good idea to demonstrate forced quit.

And I don't think Pipe will hold the child process sicne r2 is called and executed via exec.Command, so using q! is enough I guess.

XVilka commented 3 years ago

I added ForceClose() method to run q! instead. Let me know if the name is fine.

trufae commented 3 years ago

Fixed in https://github.com/radareorg/radare2/pull/18019

trufae commented 3 years ago

Merging for now. ill sync/fix the duplicated r2pipe.go repository issue