function _abc {:1 min task:_check &}function _check {wait for the previous calls of _check to complete:15 mins task:}function abc loops depending on number of tasks. It is imperative that _check is backgrounded because function abc needs to keep on working and not wait for function check to completeSo basically, what I need is for the function check to be running one at a time and not all together. That is, the remaining calls of function check should be queued up and run one at a time once the previous one finishes.
bash - queue subshells
bash;shell
Go's idea of channels can be used here:mkfifo my_pipeexec 3<>my_pipetrap 'rm my_pipe' EXITprintf a >&3function _abc {    ...    _check &}function _check {    until read -N1 -u3; do :; done    ...    printf a >&3}Essentially:Create a named pipe for communicating between instances of _abc and _check.Have _check block on a read from the pipe (one byte in the example).Start off the first _check by printing a character (doesn't matter which) to the pipe. This should perhaps done outside the function if it loops.Have each _check instance write back to the pipe on exit.To avoid writes to the pipe blocking, I added the pipe as an open file descriptor the shell (see https://unix.stackexchange.com/a/164295/70524). Also, if multiple reads are queued up on the same pipe, and one of the succeeds leaving the pipe empty, the others will report EOF. To overcome this, we have to loop on read until it succeeds in reading.