tl;dr although a tldr wont explain everything fully, i have an external program ( lets say pid 1234
) is trying to read from another external process ( lets say pid 1111
), 1111 always reads from its own stdin, but 1234 wants to handle the stdin instead of the program, but 1111 sometimes blocks 1234 from reading a byte from /proc/1111/fd/0
, which is not desired, i want to know how to make 1234 always read a byte from it and 1111 never or rarely be able to read from it
i have been trying to develop a concept for GNU BASH syntax highlighting as the only other syntax highlighter for bash i found is VERY slow because it implements the whole readline lib in BASH
i ran into some issues but came up with something working, somewhat -- https://gist.github.com/TruncatedDinosour/e2034cf470f268596235a5c88ffcd048
you can find a more in-depth explenation on it at https://blog.ari-web.xyz/b/bash-syntax-highlighting-part-one-concept/ currently i asked for general developer public for the answer, 'maybe someone knows' i thought to myself, but i think i might get an answer faster here
basically, this concept has a problem, sometimes it misses a byte because bash steals the read() i think, so far i have tried
- using
LD_PRELOAD
to overwrite theread()
function ( 'oh it surely should work' )- making always return
0
( 'okay if it falsely reads nothing surely itll work' ) - making always return
1
( 'uh, maybe lets make it think we read a single byte even though its empty ?' ) - redirecting it to a FIFO ( 'maybe just redirecting it to a different type of file would work' )
- closing it ( not sure what i was thinking here )
- making always return
- using
os.write
/read
( 'maybe directly using unbuffered syscalls would be faster, maybe its just python being slow' ) - using C++ ( 'okay surely if its a python being slow problem c++ can fix it' )
- using C ( 'okay, c++ didnt work, maybe c being a simpler language could give me more performance ?' )
currently, i never was able to fully get rid of the issue, so i thought to ask here and the general public, maybe you, fellow people, know how to achieve what im trying to achieve
thanks for any help, ideas or clues in advance :)