radareorg / radare2

UNIX-like reverse engineering framework and command-line toolset
https://www.radare.org/
GNU Lesser General Public License v3.0
20.44k stars 2.98k forks source link

Breaking #!pipe does not stop the child process #11623

Open thestr4ng3r opened 6 years ago

thestr4ng3r commented 6 years ago

Example:

[florian@florian-desktop ~]$ r2 -
 -- THE CAKE IS A PIE
[0x00000000]> & #!pipe python p.py
[0x00000000]> &
  0          running  -- MAIN TASK --
  1         sleeping  #!pipe python p.py
--
total running: 1
[0x00000000]> &b 1
Task 1 finished
[0x00000000]> ^D
[florian@florian-desktop ~]$ ps f
  PID TTY      STAT   TIME COMMAND
(...)
11156 pts/12   S      0:00 radare2 -
11157 pts/12   S      0:00  \_ python p.py

The python process is still running.

p.py:

import r2pipe
import time
r2=r2pipe.open()
while True:
        r2.cmd("?e jiji")
        time.sleep(1)

To be fixed in libr/lang/p/pipe.c. Probably by sending SIGINT to the child process and waiting for it to quit.

This issue was already present before tasks, it just didn't really become visible because if you pressed ^C while a script was running in the foreground, the SIGINT would be delivered to python instead of r2 and breaking from r2 side never happened.

trufae commented 2 years ago

This bug is in tasks, not in r2pipe