[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Interactive commands cant be backgrounded if run from bashrc
From: |
C. Yang |
Subject: |
Re: Interactive commands cant be backgrounded if run from bashrc |
Date: |
Thu, 02 Sep 2021 12:15:35 -0400 |
User-agent: |
Zoho Mail |
Hi Dale and Chet,
Thank you both for your responses and clarifications. Yes, I would like emacs
to behave as if I had typed it in the command line, in particular, to be able
to stop
and background it in the usual way.
I can confirm that adding `set -m` before the emacs command in .bashrc results
in the behavior I want with CTRL+Z. As I understand, `set -m` will enable job
control features. This suffices for my use case.
However, is it possible that there may be further unexpected consequences,
since bash is still waiting to complete initialization this entire time?
For instance, if I stop and background emacs, then I find myself back to the
bash
shell. But technically, bash is still waiting for .bashrc to complete.
It sounds like some initialization steps only happen after .bashrc completes,
so this terminal session could be missing other features.
(I don't know enough about bash, though, to know if this concern is warranted.)
Perhaps what I really want is to automatically run commands after bash
initializes completely. Perhaps I'm going about this the wrong way entirely by
trying to use .bashrc for this purpose?
Finally, Dale had written:
> Uh, "backgrounding" *is* "run it simultaneously*. I think what you mean
> is "stop and background it", which is what ctrl-Z does.
You are correct, and I appreciate the clarification. However - and this may be
specific to emacs or editor programs - when I run `emacs &` when job control is
enabled, it does appear to both background and stop the process. Again, this
seems to be a feature specific to emacs, as you are right that typically
just backgrounding with & will not also stop the process. I would of course
appreciate further clarifications if I've misunderstood.
Respectfully,
Cheshire
"When face to face with a difficulty, you are up against a discovery." - Lord
Kelvin
---- On Thu, 02 Sep 2021 10:25:15 -0400 Chet Ramey <chet.ramey@case.edu> wrote
----
On 9/1/21 2:10 PM, C. Yang wrote:
> Machine: x86_64
> OS: linux-gnu
> Compiler: gcc
> 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.
Bash doesn't initialize job control until after reading the startup files,
which are executed in a nominally non-interactive environment.
You can force that initialization by running `set -m'. It may work for your
purposes.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU mailto:chet@case.edu http://tiswww.cwru.edu/~chet/
- Interactive commands cant be backgrounded if run from bashrc, C. Yang, 2021/09/01
- Re: Interactive commands cant be backgrounded if run from bashrc, Dale R. Worley, 2021/09/01
- Re: Interactive commands cant be backgrounded if run from bashrc, Chet Ramey, 2021/09/02
- Re: Interactive commands cant be backgrounded if run from bashrc,
C. Yang <=
- Re: Interactive commands cant be backgrounded if run from bashrc, Greg Wooledge, 2021/09/02
- Re: Interactive commands cant be backgrounded if run from bashrc, Chet Ramey, 2021/09/02
- Re: Interactive commands cant be backgrounded if run from bashrc, C. Yang, 2021/09/02
- Re: Interactive commands cant be backgrounded if run from bashrc, Chet Ramey, 2021/09/02
- Re: Interactive commands cant be backgrounded if run from bashrc, C. Yang, 2021/09/02