From: cheshire (he...@cheryllium.com)

To: mailto:bug-bash@gnu.org

Subject: Interactive commands cant be backgrounded if run from bashrc

 

Configuration Information [Automatically generated, do not change]:

Machine: x86_64

OS: linux-gnu

Compiler: gcc

Compilation CFLAGS: -g -O2 
-fdebug-prefix-map=/build/bash-a6qmCk/bash-5.0=. 
-fstack-protector-strong -Wformat -Werror=format-security -Wall 
-Wno-parentheses -Wno-format-security

uname output: Linux cyang_2021 4.4.0-19041-Microsoft #1151-Microsoft Thu Jul 22 
21:05:00 PST 2021 x86_64 x86_64 x86_64 GNU/Linux

Machine Type: x86_64-pc-linux-gnu

 

Bash Version: 5.0

Patch Level: 17

Release Status: release

 

Description:

  Whenever I start my session, I'd like to automatically open emacs to a 
specific file.

  So, I added the emacs command to the bottom of my ~/.bashrc file. This opens 
emacs

  correctly when I start the session.

 

  Normally, when I start emacs, I can background the process with CTRL+Z, and 
foreground

  with `fg` command. When emacs is started from .bashrc as above, pressing 
CTRL+Z does

  not correctly background the process. Instead, the terminal session goes 
blank and

  becomes unresponsive.

 

  This may be because the bashrc file is still running, and bash itself perhaps 
does

  not finish initializing until everything in the bashrc completes. This may be 
why

  CTRL+Z does not work correctly (it might require bash to finish initializing 
first)

 

  While trying to find a workaround, we tried to start the process in 
background,

  and then foreground it, within the bashrc. So instead of `emacs test.txt`, we

  tried:

 

      emacs test.txt &

      fg

 

  The first line, instead of backgrounding emacs, appeared to run it 
simultaneously

  with bash. This had the consequence that both bash and emacs were taking the 
same

  keyboard input and trying to render to the same screen.

 

  The second line crashes with the error:

 

      bash: fg: no job control

 

  (Probably doesn't need to be said, but these commands work if taken out of 
the bashrc,

  and run manually in the shell after bash is allowed to finish initialization.)

 

Repeat-By:

  1. Add the following line to bottom of your bash init file:

         emacs test.txt # doesn't matter

  2. Start a new session (let it open emacs too)

  3. Press CTRL+Z

 

Reply via email to