[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Interactive commands cant be backgrounded if run from bashrc

From: C. Yang
Subject: Interactive commands cant be backgrounded if run from bashrc
Date: Wed, 01 Sep 2021 14:10:00 -0400
User-agent: Zoho Mail

From: cheshire (hello@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 
-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



  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 

  correctly when I start the session.


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

  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 

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

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


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

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



      emacs test.txt &



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

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

  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.)



  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

[Prev in Thread] Current Thread [Next in Thread]