[olug] Bash or CygWin quirk waiting for process...

Jay Bendon jaybocc2 at gmail.com
Tue Jul 4 12:44:11 CDT 2017


try

bash -c "mintty -t Type-A --exec ./build.sh typeA" &
bash -c "mintty -t Type-A --exec ./build.sh typeB" &
jobs -p
wait

--Jay

On Mon, Jul 3, 2017 at 7:57 AM, Dan Linder <dan at linder.org> wrote:

> Thanks for the responses, sorry for the slot reply with update.
>
> I made a simple script with just these lines in a file:
>
> /usr/bin/mintty /usr/bin/bash &
> /usr/bin/mintty /usr/bin/bash &
> jobs -p
> wait
>
>
> Running that file in the Git bash (/usr/bin/bash version 4.4.12) on my
> Windows 10 system the terminal windows open, the "jobs -p" shows the two
> PIDs, but the script exits seemingly ignoring the "wait".
>
> The wait command works if I replace the mintty calls with sleep commands
> like this:
>
> sleep 3 &
> sleep 5 &
> jobs -p
> wait
>
>
> The "jobs -p" output shows the new PIDs, AND the wait command holds up the
> script until both of the sleeps exit.  Thinking it might be related to
> calling another binary, I made a small sleep.sh script (contents: "sleep
> $1") and executed "/usr/bin/bash sleep.sh 3" but the wait works as
> expected.
>
> Thinking it was a problem with a new window being opened I replaced it with
> /usr/bin/notepad but wait still works:
>
> /usr/bin/notepad /tmp/file1 &
> /usr/bin/notepad /tmp/file2 &
> jobs -p
> wait
>
>
> I don't know why "/usr/bin/mintty" is special but apparently it is
> somehow.  Guess I'll keep plugging away at it and keep everyone informed if
> I reach a breakthrough.
>
> Dan
>
> On Thu, Jun 29, 2017 at 6:19 PM, David Gilman <davidgilman1 at gmail.com>
> wrote:
>
> > If you use wait without an argument it'll block until all child
> > shells/processes finish.  So I think you can take out the for loop and
> your
> > use of jobs entirely, and your script becomes:
> >
> > mintty foo &
> > mintty bar &
> >
> > wait
> >
> >
> > On Thu, Jun 29, 2017 at 7:01 PM, Boian Berberov (Public) <
> > bberberov at gmail.com> wrote:
> >
> > > You might have to trim the output of jobs -p.  Mine gives extra info.
> > >
> > > Respectfully,
> > >
> > > Boian Berberov
> > > _________________________
> > > https://boian.berberov.eu
> > >
> > > On 29/06/17 17:25, Dan Linder wrote:
> > > > I'm using CygWin in Windows 10 to automate a process.  I have two
> child
> > > > shell scripts I want to kick off from my main script, but I want the
> > main
> > > > script to hang around until both of the child scripts are done.
> > > >
> > > > The two child scripts are called as processes of "mintty" so the
> output
> > > of
> > > > each is in separate windows.
> > > >
> > > > Here's my script:
> > > >
> > > > #!/bin/bash
> > > > mintty -t Type-A --exec ./build.sh typeA &
> > > > mintty -t Type-B --exec ./build.sh typeB &
> > > >
> > > > for job in `jobs -p` ; do
> > > >   echo Waiting for child $job of jobs: `jobs -p` to exit.
> > > >   wait $job
> > > > done
> > > >
> > > > ./process_both.sh
> > > >
> > > >
> > > > Both of the MinTTY consoles open and run the script, but the wait
> > > for-loop
> > > > doesn't wait and the "process_both.sh" script fires right away.
> > > >
> > > > Any ideas?
> > > >
> > > > Dan
> > > >
> > > >
> > > _______________________________________________
> > > OLUG mailing list
> > > OLUG at olug.org
> > > https://lists.olug.org/mailman/listinfo/olug
> > >
> >
> >
> >
> > --
> > David Gilman
> > :DG<
> > _______________________________________________
> > OLUG mailing list
> > OLUG at olug.org
> > https://lists.olug.org/mailman/listinfo/olug
> >
>
>
>
> --
> ***************** ************* *********** ******* ***** *** **
> "If you wish to make an apple pie from scratch,
>   you must first invent the universe."
>   -- Carl Sagan
>
> "Quis custodiet ipsos custodes?"
>     (Who can watch the watchmen?)
>     -- from the Satires of Juvenal
>
> "I do not fear computers, I fear the lack of them."
>     -- Isaac Asimov (Author)
> ** *** ***** ******* *********** ************* *****************
> _______________________________________________
> OLUG mailing list
> OLUG at olug.org
> https://lists.olug.org/mailman/listinfo/olug
>


More information about the OLUG mailing list