Closed BarbzYHOOL closed 9 months ago
I don't know any way to detect if the current process is waiting for user input. @jorgebucaran any ideas?
@BarbzYHOOL Do you mean when a background process is hanging? 🤔
Example: you run ansible which auto installs stuff, and at some point, it asks for a prompt (or it asks at start but you launch ansible and you immediately alt+tab) but you're doing something else and the auto install never completes because of that.
@BarbzYHOOL Would ansible run as a background job in a subshell or in a different shell like on a new tab or window?
In a new window because it takes a long time so I switch, and not in background (basically that's what "done" is about :P and in new tab it's not detected, I already opened an issue for new tab and i looked on google, but didn't find how to make "done" work with new tabs)
Unfortunately this doesn't look like something that can be trivially implemented.
If using tmux you could check the last line of the terminal and pattern match it.
e.g. tmux capture-pane -p -t "paneid" | tac | grep -E -m 1 . | sed -e 's/^[ \t]*//'
If it was stuck at a sudo prompt it would return:
[sudo] password for yourusename:
Then if the window was not focused you could send a notificiation.
Caveats:
done
notification runs on command completion, so it's not really compatible with this method since you have to keep polling the status line. Might be an idea for another script?That would require to know that the program is stuck into a read
syscall on stdin
, that sounds very difficult IMHO
Marked as wontfix
since nobody can see how this would be possible, but feel free to comment if someone has an idea.
I don't know if it's possible but what about warning the user when the program is hanging or when there is a prompt to answer?
That would be really really helpful