Skip to content

Can't get the example to works #3

@rockandska

Description

@rockandska

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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions