xonsh / xonsh

:shell: Python-powered shell. Full-featured and cross-platform.
http://xon.sh
Other
8.44k stars 641 forks source link

Xonsh freezes if a command is entered while another command is running #4078

Closed aneeshdurg closed 5 months ago

aneeshdurg commented 3 years ago

xonfig

``` # vim: set syntax=python # pip install prompt-toolkit first! import xonsh.jobs import builtins import json from math import * from termcolor import colored xontribs = [ "abbrevs", "coreutils", "fzf-widgets", "z" ] for x in xontribs: xontrib load @(x) $AUTO_CD = True $VI_MODE = True $PROMPT = '{env_name}{BOLD_GREEN}{user}@{hostname}{RESET}:{BOLD_BLUE}{cwd}{RESET}{prompt_end}{RESET} ' $fzf_history_binding = "c-r" # Ctrl+R $fzf_file_binding = "c-f" # redshift shortcuts abbrevs['rsx']='redshift -x' abbrevs['rson']='redshift -O 3500' # configure view to work with nvim abbrevs['view']='nvim -R' aliases['cat'] = 'batcat' $GEM_HOME = f"{$HOME}/gems" $PATH.append("$HOME/gems/bin") def getvim(): if 'NVIM_ACTIVE' in ${...}: return 'nvr -cc vsp' else: return 'nvim' def nvim_header(): # Visual indicator that I'm in a neovim subshell if 'NVIM_ACTIVE' in ${...}: output = $(figlet -f small "NVIM SUBSHELL") print(colored(output, 'green')) if "NVIM_LISTEN_ADDRESS" not in ${...}: $NVIM_LISTEN_ADDRESS = p"/tmp/nvimsocket" $EDITOR = getvim() if 'NVIM_ACTIVE' in ${...}: $EDITOR = f"{getvim()} --remote-wait" $HGEDITOR = "/bin/hgeditor.sh" aliases['vim'] = getvim() def tmux_status(): echo -ne "Running tmux sessions: \n\t\033[1;32m" tmux ls echo -ne "\033[0m" def startup(): ~/dotfiles/.quotes.py nvim_header() tmux ls err>/dev/null o>/dev/null && tmux_status() startup() orig_z = aliases['z'] def _z(args=[]): if args: return orig_z(args) else: return orig_z([""]) aliases['z'] = _z def _disown(args, stdin=None): """xonsh command: disown Remove background jobs from xonsh shell handling so that they will continue running after the shell exits. an arbitrary number of jobIDs may be specified as arguments. If no arguments are specified, all jobs will be disowned. """ if len(xonsh.jobs.tasks) == 0: return "", "There are no active jobs" if len(args) > 0: try: to_disown = [xonsh.jobs.tasks[tid] for argv in args if (tid := int(argv) - 1) >= 0] except ValueError: return "", "One or more jobsIDs is invalid: {}\n".format(args) else: return "", "Must specify 1 or more job IDs." for tid in to_disown: current_task = xonsh.jobs.get_task(tid) # Resume the task in case it is paused xonsh.jobs._continue(current_task) # Stop tracking this task xonsh.jobs.tasks.remove(tid) del builtins.__xonsh__.all_jobs[tid] # the shell won't exit normally if there are disowned procs, but the # procs continue to run.. current_task['obj'].proc.poll = lambda: True current_task['obj'].poll = lambda: 0 aliases['disown'] = _disown ```

Expected Behavior

Xonsh should allow inputting a command while another command is running and not freeze afterwards

Current Behavior

While a command is running, if you enter another command, xonsh will freeze when entering a subsequent command.

Steps to Reproduce

$ sleep 5
echo hi # <- entered while sleep was running
$ echo hi
hi
$ clear
# freezes here

For community

ā¬‡ļø Please click the šŸ‘ reaction instead of leaving a +1 or šŸ‘ comment

anki-code commented 3 years ago

$ sleep 5 echo hi # <- entered while sleep was running $ echo hi hi $ clear freezes here

Hi! I can't reproduce this in xonsh --no-rc (xonsh/0.9.25.dev3) on Ubuntu 20.04.

aneeshdurg commented 3 years ago

Interesting, it repros with xonsh --no-rc for me on Ubuntu 20.04. I'm using xonsh 0.9.24 though, will try again with the latest version.

aneeshdurg commented 3 years ago

Yup, looks like this is fixed in master.

aneeshdurg commented 3 years ago

Actually it seems like it's only fixed when I run it in docker. Installing it to my system causes the issue to repro. For more info, I'm using urxvt as the terminal.

anki-code commented 3 years ago

This looks like need more debugging for reported terminal.

anki-code commented 5 months ago

I'm going to close this because I can't reproduce this on the current main branch.