Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get the example to works #3

Open
rockandska opened this issue Oct 14, 2020 · 3 comments
Open

Can't get the example to works #3

rockandska opened this issue Oct 14, 2020 · 3 comments

Comments

@rockandska
Copy link

Hi there,

I can't get ctrl+g to print hello world in interactive python shell as described in the example.

 ~/Documents/Git/rl_custom_function $ cat ~/.inputrc 
$include function hello_world /tmp/hello_world.so
"\C-g": hello_world
 ~/Documents/Git/rl_custom_function $ rustc example/hello_world.rs -o /tmp/hello_world.so
 ~/Documents/Git/rl_custom_function $ cargo build --release --target-dir /tmp
    Finished release [optimized] target(s) in 0.01s
 ~/Documents/Git/rl_custom_function $ LD_PRELOAD=/tmp/release/librl_custom_function.so python &> /dev/null &
[1] 15913

[1]+  Stopped                 LD_PRELOAD=/tmp/release/librl_custom_function.so python &> /dev/null
 ~/Documents/Git/rl_custom_function $ lsof -p 15913 
COMMAND   PID       USER   FD   TYPE DEVICE SIZE/OFF     NODE NAME
python  15913 rockandska  cwd    DIR  253,0     4096 18350412 /home/rockandska/Documents/Git/rl_custom_function
python  15913 rockandska  rtd    DIR  253,0     4096        2 /
python  15913 rockandska  txt    REG  253,0  3665768 13238471 /usr/bin/python2.7
python  15913 rockandska  mem    REG  253,0   170784 20452146 /lib/x86_64-linux-gnu/libtinfo.so.5.9
python  15913 rockandska  mem    REG  253,0   294632 20452126 /lib/x86_64-linux-gnu/libreadline.so.7.0
python  15913 rockandska  mem    REG  253,0    27168 13243713 /usr/lib/python2.7/lib-dynload/readline.x86_64-linux-gnu.so
python  15913 rockandska  mem    REG  253,0  3008800 13240303 /usr/lib/locale/locale-archive
python  15913 rockandska  mem    REG  253,0    96616 20447293 /lib/x86_64-linux-gnu/libgcc_s.so.1
python  15913 rockandska  mem    REG  253,0    31680 20449149 /lib/x86_64-linux-gnu/librt-2.27.so
python  15913 rockandska  mem    REG  253,0  1700792 20448770 /lib/x86_64-linux-gnu/libm-2.27.so
python  15913 rockandska  mem    REG  253,0   116960 20452160 /lib/x86_64-linux-gnu/libz.so.1.2.11
python  15913 rockandska  mem    REG  253,0    10592 20449153 /lib/x86_64-linux-gnu/libutil-2.27.so
python  15913 rockandska  mem    REG  253,0    14560 20448769 /lib/x86_64-linux-gnu/libdl-2.27.so
python  15913 rockandska  mem    REG  253,0   144976 20449138 /lib/x86_64-linux-gnu/libpthread-2.27.so
python  15913 rockandska  mem    REG  253,0  2030544 20448764 /lib/x86_64-linux-gnu/libc-2.27.so
python  15913 rockandska  mem    REG  253,0  2553688 22682962 /tmp/release/librl_custom_function.so
python  15913 rockandska  mem    REG  253,0   170960 20447613 /lib/x86_64-linux-gnu/ld-2.27.so
python  15913 rockandska    0u   CHR  136,1      0t0        4 /dev/pts/1
python  15913 rockandska    1w   CHR    1,3      0t0        6 /dev/null
python  15913 rockandska    2w   CHR    1,3      0t0        6 /dev/null
 ~/Documents/Git/rl_custom_function $ lsof -p 15913 | grep readl
python  15913 rockandska  mem    REG  253,0   294632 20452126 /lib/x86_64-linux-gnu/libreadline.so.7.0
python  15913 rockandska  mem    REG  253,0    27168 13243713 /usr/lib/python2.7/lib-dynload/readline.x86_64-linux-gnu.so

It seems that it tries to include function hello_world /tmp/hello_world.so instead of /tmp/hello_world.so as if the function rl_bind_and_parse is not override by the LD_PRELOAD library

 ~/Documents/Git/rl_custom_function $ LD_PRELOAD=/tmp/release/librl_custom_function.so strace -o /tmp/strace `which bash`
 ~/Documents/Git/rl_custom_function $ grep librl_custom_function.so /tmp/strace
openat(AT_FDCWD, "/tmp/release/librl_custom_function.so", O_RDONLY|O_CLOEXEC) = 3
write(2, "librl_custom_function.so", 24) = 24
 ~/Documents/Git/rl_custom_function $ grep hello_world /tmp/strace
read(3, "$include function hello_world /t"..., 70) = 70
stat("function hello_world /tmp/hello_world.so", 0x7ffe6e61fe80) = -1 ENOENT (No such file or directory)
write(2, "hello_world /tmp/strace\10\10\10\10\10\10\10\10\10"..., 35) = 35

Any ideas ?

@lincheney
Copy link
Owner

hi, sorry i have not been paying attention to this repo :(
Did you ever figure this one out?

Do you have an strace for the python instead? bash is quite different as it is quite often statically linked with readline so LD_PRELOAD won't work with it

@carlfriedrich
Copy link

I have the same problem, nothing happens on pressing ctrl+g in Python.
@rockandska Did you manage to get this working?
@lincheney Is there a way to investigate why nothing happens? What do you mean with "bash is quite different"? Different to what?

@lincheney
Copy link
Owner

I think you already noticed, it is likely related to this lincheney/fzf-tab-completion#75

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants