Questions tagged [job-control]
Questions about the various ways jobs can be controlled by the shell: suspending, resuming, terminating execution etc.
233 questions
6
votes
2
answers
657
views
Are some bash ambiguous job specs impossible to differentiate?
$ sleep 1234&
$ sleep 12345678&
$ %sleep\ 1234
bash: fg: sleep 1234: ambiguous job spec
$ jobs
[1]- Running sleep 1234 &
[2]+ Running sleep 12345678 &
...
0
votes
1
answer
72
views
disable bash job control warning "job specification requires leading `%'"?
I just rebooted one of my systems for the first time in several months, restarted tmux and my usual set of bash shells for tailing various log files, and noticed that running fg n (i.e. fg followed by ...
4
votes
1
answer
313
views
Run in background avoiding any job control message from the shell [duplicate]
Lets define a shell function (here the shell is Bash) and test it
$ s () { xterm -e sleep 5 & }
$ s
[1] 307926
$
[1]+ Done xterm -e sleep 5
$
With my specific meaning of ...
0
votes
0
answers
42
views
spawn process with existing session ID (setsid, maybe use GDB)
How to create a new process with the session ID (setsid) of an existing process?
I have an idea using GDB which is working partly. But I'm also thankful for other approaches.
.
There seems to be no ...
2
votes
0
answers
85
views
bash ctrl-z to send a for loop in background, only the currently run command is resumed when bg
poc:
$ for i in $( seq 1 10 ); do echo "begin $i"; sleep 4 ; echo " end $i" ; done
begin 1
end 1
begin 2
end 2
begin 3
## after 1 second, I : ctrl-z
^Z
[1]+ Stopped ...
2
votes
1
answer
130
views
Why does bash (executing the script) stay in the foreground group when executing commands in a script?
I am using the following version of the bash:
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
When I start some command (e.g. ./hiprogram) directly from the terminal, then bash forks itself,...
0
votes
0
answers
119
views
How Do SSH-Launched Long-Running Background Jobs Detach Without nohup or disown?
When running a long-running command in the background over SSH from a non-interactive shell script, I noticed the process continues running on the remote machine without using nohup, disown, or ...
0
votes
1
answer
166
views
How to run linux command in jobs, when to run bash script [closed]
I want to run those command in linux jobs, so when I tyep "jobs", I can mannage those jobs, how to do it ( in bash script)
1
vote
1
answer
106
views
Prevent SIGINT propagation from subshell to parent shell in Zsh
I need to prevent SIGINT (Ctrl-C) from propagating from a subshell to its parent shell functions in Zsh.
Here's a minimal example:
function sox-record {
local output="${1:-$(mktemp).wav}"...
2
votes
1
answer
103
views
Is there a way to `exec` a pipeline or exit shell after launching a pipeline?
I'm writing a shell wrapper script that is supposed to act as a pager (receiving input on stdin and performing output on a tty).
This wrapper prepares environment and command lines, then launches two ...
0
votes
1
answer
328
views
SIGTSTP(Ctrl-Z) not working for script started by script command
Note: script refers to the script command,
which logs stdin and stdout to files.
I was trying to run a script with the script utility to save output
for later inspection while preserving text colors ...
0
votes
2
answers
135
views
Add a process to an already executing process? Like && or so
This question inspired me to another related question. Imagine that you start
% nohup a.sh &
and then want b.sh to execute when a.sh is finished (E.g., b.sh will process the output from a.sh. ...
5
votes
3
answers
1k
views
How to cleanup on suspense (ctrl-z) in a Bash script?
I have the following script:
suspense_cleanup () {
echo "Suspense clean up..."
}
int_cleanup () {
echo "Int clean up..."
exit 0
}
trap 'suspense_cleanup' SIGTSTP
trap '...
1
vote
2
answers
899
views
Does any terminal multiplexer (screen, tmux, zellij) support job suspension (Ctrl-Z) in Bash?
As far as I've seen, pressing Ctrl-Z on any terminal multiplexer, or trying to start them in the background, does nothing or crashes.
I know that, in a sense, terminal multiplexers are a "...
29
votes
2
answers
6k
views
Why does "yes&" crash my Bash session?
"Yes, and..." is a wonderful rule-of-thumb in improvisational comedy. Not so much in the UNIX world.
When I run the admittedly silly yes& command, I cannot interrupt it. The terminal ...