How do I know if the terminal is running a command? #4575
-
In the webUI I have a button to input commands to the xterm automatically, I want to know if the console is "busy", so that I won't inject the input sequence and tell user what's happening. How can I know if the console is busy? e.g running vim |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Well - you cant. A terminal is just an IO device for interactive keyboard input and screen output, where the OS redirects process some explanation So nope - it is conceptually not possible, as any of the processes might read/write to the terminal. The TTY as found on POSIX systems is simply not made for that. Only the kernel knows all the needed the details in the end, so well - it might be possible with a kernel module hooking into TTY abstraction 🙈. |
Beta Was this translation helpful? Give feedback.
Well - you cant. A terminal is just an IO device for interactive keyboard input and screen output, where the OS redirects process
stdin
andstdout
to (through TTY/PTY abstraction).some explanation
The commands are launched by another process, typically a shell. It is important to understand that terminal != shell - if you want control/knowledge about the processes being spawned and attached to the TTY, you'd have to hook into the shell's command evaluation (the E in REPL). With an interactive shell + command execution the situation gets further complicated by the fact, that commands can be interactive itself (its own REPL) temporar…