Questions tagged [wait]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
-2
votes
3answers
90 views

What is the relation between SIGCHLD and `waitpid()` or`wait()`?

If I am correct, a process waits for its children to terminate or stop by calling the waitpid() or wait() function. What is the relation between SIGCHLD signal and the waitpid() orwait() functions? ...
9
votes
1answer
1k views

Press SPACE to continue (not ENTER)

I know this question has been already asked & answered, but the solution I found listens for space and enter: while [ "$key" != '' ]; do read -n1 -s -r key done Is there a way (...
2
votes
1answer
40 views

Why is the wait $pid command interrupted by any signal to the waiting process?

I can't find any documentation that explains my observations in sufficiently enough terms. After I run the below code, I perform a kill -SIGINT $my_pid from a different shell. I will correctly see ####...
17
votes
1answer
1k views

When and why do we need the `wait` command on bash?

Doesn't the bash shell already run the commands one by one and wait for the executed command to finish? So when and why do we need the wait command?
0
votes
1answer
58 views

Bash function that will wait for a process to be finished before starting a new one

I'd like to create a function that will wait until a job is completed before starting a new process. I'm aware of the wait command that is built into bash, but it only works for child processes. It ...
0
votes
0answers
49 views

Does wait work without SIGCHLD?

I have a parent process that runs a child process and then wait for it: myprocess & wait $! However, when myprocess exits, the parent process continues waiting for it. After listing the signals ...
3
votes
1answer
95 views

What determines whether a script's background processes get a terminal's SIGINT signal?

#!/usr/bin/env bash sleep 3 && echo '123' & sleep 3 && echo '456' & sleep 3 && echo '999' & If I run this, and send SIGINT by pressing control-c via terminal, it ...
0
votes
1answer
234 views

Press ENTER to continue

I want to know if there is any way to make my script stop until the user hits the Enter key, but without using the command read, just by the options of stty. I was wondering a code for this and got ...
0
votes
1answer
56 views

Can I wait for all forked processes from a command to finish?

Suppose running FOO stars BAR in the background. How can I wait for BAR to finish in the shell? I want a solution where I don’t change the internals of FOO (though I can grudgingly change BAR’s.). ...
2
votes
1answer
54 views

Question about a process lifecycle

I've managed to question myself about the wait(2) and _exit(2) system calls in a process lifecycle. My question about the wait(2) system call is... does the parent process issue it to the kernel? Or ...
0
votes
1answer
245 views

Why SIGCHLD signal was not ignored when using wait() functions?

When using wait functions the SIGCHLD signal was consumed by wait when executing sample 1.1 as shown below. sample 1.1 if (pid==0){ printf("child\n"); printf("%d\n",pid); } else{ printf("...
0
votes
0answers
59 views

Receiving SIGKILL when children terminate

I want to receive SIGKILL instead of SIGCHLD when any of my forked children terminate. On Linux this is possible by passing a different child termination signal to clone()1. Is this possible on any ...
0
votes
2answers
184 views

`wait` for processes started in a for loop, but not others started earlier

Suppose I have several running background tasks, but now I want to run two more background tasks, but wait only for the last two. For example: # long running commands sleep 60 & sleep 60 & # ...
0
votes
0answers
18 views

Red Hat: Back-Off time during failed authentication attempts

I am searching for a way to configure some sort of back-off or wait time during failed authentication attempts. The idea is that after each failed authentication attempt, the user has to wait an ...
2
votes
2answers
121 views

queue-like behaviour for multiple one-core jobs on single machine? [duplicate]

I've got an old Mac with 24 cores, and I'd like to run several hundred/thousands one-core jobs automatically. I've made a bash script that runs the processes in the background, but if I set too many ...
1
vote
1answer
1k views

Script hanging when using tee and wait, why?

I'm running a script which automates snapraid for my NAS server. It's a script I found online and it was working without issue on Debian 9. I updated to Debian 10 last week and the script now hangs in ...
3
votes
1answer
309 views

Kill the child process in a child xterm but not xterm

I'm new to Linux. I have python scripts in different files, each one performing a desired function. foo1.py foo2.py foo3.py Each one of these scripts should do cleanup before being terminated. ...
3
votes
2answers
145 views

Regain ability to use ^C to close backgrounded then (effectively) foregrounded processes

In the interactive console, pressing ^C on zenity --info & fg closes the Zenity window. One can only use zenity --info & wait in a script. But ^C doesn't close the Zenity window in this case. ...
0
votes
1answer
571 views

how signals are handled in linux kernel [closed]

My question is about signals and handling them inside the operating system kernel. I know that every process has it own signal_handler() table: a 31 bit array for signals (pending_signals), and when a ...
1
vote
0answers
809 views

How to wait for the execution of a python script inside shell script?

I want to mount another root partition, edit the grub.cfg file with a python script and afterwards umount the partition again. How can I wait for the python script to finish and check if the partition ...
3
votes
1answer
486 views

What does the `-f' option do for `wait' versus the default behaviour?

Bash 5.0 includes a new -f option for wait:[1] j. The `wait' builtin now has a `-f' option, which signfies to wait until the specified job or process terminates, instead of waiting until it ...
0
votes
2answers
2k views

Why should parent process wait (to terminate) until all of its child process terminates?

I know there is no enforcement for the parent process to wait until all its child process terminates. However it's a convention followed. Furthermore, I know that if parent process terminates before ...
0
votes
1answer
344 views

tmux send-keys confirm ssh tunnel is closed (after sending multiple commands to the remote host) before proceeding

there is an answer here about tmux using wait-for and LocalCommand to wait until the SSH connection is established before continuing, but I needed a way to have tmux wait for the ssh session to be ...
8
votes
3answers
3k views

sleep, wait and Ctrl+C propagation

If I have the following shell script sleep 30s And I hit Ctrl+C when the shell script is running, the sleep dies with it. If I have the following shell script sleep 30s & wait And I hit Ctrl+...
0
votes
1answer
100 views

How can I make `enscript` block till the printer finishes its job?

The following command will create a pdf file under ~/PDF/: enscript -B -P PDF bloom.c I want to move the output pdf file here ...
-1
votes
2answers
613 views

Wait command works when pid doesn't exists

I'm facing an unexpected behaviour of the wait builtin. ~ ❯ sleep 1 & [1] 72009 ~ ❯ [1] + 72009 done sleep 1 ~ ❯ wait 72009 ~ ❯ echo $? 0 Although the PID doesn't exist anymore wait ...
0
votes
2answers
578 views

Use waitpid for child having groupid 1

I searched a lot but didn't find a solution. So it can be silly question. The format of waitpid is pid_t waitpid (pid_t pid, int *status, int options) The pid parameter specifies exactly which ...
2
votes
1answer
4k views

How do I wait for nohup jobs to finish within a shell script?

I have the following script: echo "$wk" | while read -r a b; do counter=$(($counter+1)) nohup sh -c 'impala-shell -d nielsen -f query.sql --var=dt=$a --var=incre=$b; echo $a,$?>>$...
2
votes
3answers
1k views

Bash script to wait for a process to finish on multiple servers [duplicate]

I wanted to ssh to multiple servers remotely and check whether any processes running on those servers and wait until the process to get finished. I have written the below code but this checks only for ...
2
votes
1answer
454 views

Run subshells in parallel and collect exit codes

I have the following, I thought it ran the subshells in parallel, but it actually seems to run them in series, and I cannot figure out why: #!/usr/bin/env bash set -e; set -m # allow for job control ...
16
votes
2answers
38k views

Run commands in parallel and wait for one group of commands to finish before starting the next

I have script including multiple commands. How can I group commands to run together ( I want to make several groups of commands. Within each group, the commands should run in parallel (at the same ...