I'm currently working on an audit-script for a huge platform. In the main-script we use traps and in one of the traps I ask the user for clean up the files. The script has no output in standard output, so running the script in the bg is obvious.
When sending a SIGQUIT to the bg-job it stops, and I have to put it manually in the foreground with
fg to get the prompt.
What I tried:
I played around with
set -m to active job control and put an
fg into my trap-function.
set -m my shell close after the script finished, without it I get debug-output, that my script doesn't have job control. Even with
set -m, the job doesn't come into foreground.
For this, my questions are:
- Is it possible to force a job to come into foreground at some point?
- I know this is not the common way to use job-control inside a script. What is "best practise" for this?
- Is job-control inside a script only for sub-shells/child-processes or can I use it to control the job I started?
as lcd047 suggested it is much more elegant to use
tmux, to keep the scripts clean and simple.