I know I can create new sub-shells (please correct me on terminology) in bash by using &. However this requires me to hit Control-c to get back to bash with most programs. Is there a way to stop this from happening so once I invoke a command i.e urxvt -e bash & I don't have the current shell hang, or is this behaviour to do with urxvt?

  • Your shell shouldn't "hang" when you run urxvt -e bash & (which runs urxvt as a background job, not as a subshell). It should print a job it (eg. [3] 4368) and then print the prompt again. I guess you have some special PS1 or PROMPT_COMMAND in your bash config, or something else's broken. Will it also show the prompt if you hit Enter instead of Control-C? – mosvy May 10 '19 at 16:52
  • no, hitting return has no effect. It's kind of like when a process tries to read stdin. – myc3lium May 10 '19 at 17:00
  • does it also happen if you start a shell like PS1='\$ ' bash --norc and then start your urxvt & command from within it? – mosvy May 10 '19 at 17:03
  • The same thing still happens, only difference being that hitting return has the appropriate effect. If it helps at all, Urxvt prints "urxvt: no visual found for requested depth 100, using default visual" when started. – myc3lium May 10 '19 at 17:10
  • That's expected when a bg job prints something to the tty. So you really have something "interesting" in your ~/.bashrc (or /etc/bash.bashrc on Debian-like systems). – mosvy May 10 '19 at 17:16

The shell will not hang when you start a background job. It may not display the prompt as usual (or it may be slightly obstructed if the background job produces any output in the terminal), but whatever you type into the shell at that point will definitely be entered into the shell as usual.

There is no need to press Ctrl+C after starting a background job. You could possibly press Enter to get the shell to re-display your prompt.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.