Score:0

In Linux/bash how can I prevent asynchronous commands?

vn flag

I have a makefile that calls external build scripts.

Some of these scripts (which I can't change) make use of commands that are forked / backgrounded (or asynchronous as the bash manual names them)

That means that the next line in the makefile can start before some of the previous command finishes - creating a race condition.

I somehow need to either wait on the forked process and all it's children, or simply prevent any command or subcommand of subsequent scripts running in the background.

Is there a way to prevent this, i.e. disable the ampersand '&' suffix to commands in the current and child subshells?

Score:0
in flag

One possible way is to create a copy of these scripts and remove the constructions with make some command to run in background. Be warned you may do not want to remove all & automatically because you may mess commands like:

command && command 

The other possible way is to ask for permission to edit the scripts (instead of copy them)

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.