Git BASH, MinTTY, and background/wait

276 views
Skip to first unread message

Dan Linder

unread,
Jun 22, 2017, 9:32:46 AM6/22/17
to git-for-windows
Forgive me if this is the wrong group to post this to.  I'm writing a simple shell script to kick off a few long-running tasks in parallel on my Windows 10 system running "GNU bash, version 4.4.12(1)-release (x86_64-pc-msys)".

Here's my test code:
#!/bin/bash
set -x
echo ==== Working with sleep ====
echo Start first process
sleep 4 &
echo Start second process
sleep 5 &
echo Waiting PIDS: $(jobs -p)
# https://stackoverflow.com/questions/356100/how-to-wait-in-bash-for-several-subprocesses-to-finish-and-return-exit-code-0
for job in `jobs -p` ; do
  echo Waiting for child $job of jobs: `jobs -p` to exit.
  wait $job
done 
 
echo ==== Fails with mintty ====
echo Start first process
mintty -t sleep-4 sleep 4 &
echo Start second process
mintty -t sleep-5 sleep 5 &
echo Waiting PIDS: $(jobs -p)
# https://stackoverflow.com/questions/356100/how-to-wait-in-bash-for-several-subprocesses-to-finish-and-return-exit-code-0
for job in `jobs -p` ; do
  echo Waiting for child $job of jobs: `jobs -p` to exit.
  wait $job
done
 


The upper half of the code waits for the two "sleep" processes to complete before exiting the for loop.

The second half of the code (starting at "Fails with mintty") is the same code but with the "sleep" commands changed to call "mintty" instead.  When this runs, the MinTTY terminals open and sleep for the requested time, BUT the "jobs -p" doesn't see the sleeping MinTTY processes so the for loop exits even though the MinTTY windows are still running.

Is there something special about calling MinTTY that I'm missing?

Thanks!
Dan
Reply all
Reply to author
Forward
0 new messages