Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • 2
    Does the locking offered by sem handle being shot down mid-execution? Commented Nov 10, 2016 at 0:56
  • Regarding "the output isn't displayed until it finishes": You can disable the buffering using -u or --lb, see man parallel. Commented Sep 10, 2020 at 21:15
  • @roaima Yes, sem seems to correctly handle shutdowns like ctrl+c and even a brutal kill -9 (SIGKILL). You can try this using timeout -s9 1 sem -u --id myid --fg 'echo a; sleep 3; echo b'; sem -u --id myid --fg 'echo c'. For a better test, run this check in a loop and vary the timeout. In each iteration a c should be printed. Endless test: shuf -re {00..40} | while read t; do printf a; timeout -s9 0.$t sem -u --id myid --fg 'sleep 0.2; printf b'; sem -u --id myid --fg 'printf c'; echo d; done | grep '[^c]d'. No output means everything works fine. Commented Sep 10, 2020 at 21:16