David Niklas
2018-08-29 15:39:32 UTC
On Thu, 16 Aug 2018 10:52:32 +0200
Hey! Sorry this is so late, but it seems nobody is helping you and I tend
to be the last to respond.
export OCD="$!";
sleep 15s;
kill $H;
wait $H;
if [ $H -ne 0 ]; then exit; fi
exit $?;
I do not have openocd, nor am I aware of how you intend to tell openocd
to access your pipe in order to pipe data so I have not tested all of the
above code. You might have to use a socket instead if you want
bidirectional communication, but I have no experience there so you will
have to wait for someone else to help you.
Even more confusing to me is that you want to run gdb in the foreground
but you also want to wait for the return of openocd!? Both are not
simultaneously possible. Esp. because gdb will prevent openocd from
exiting, or at least that is what happens when my code fouls up. Then I
run the bt command from within gdb.
Sincerely,
David
Hey! Sorry this is so late, but it seems nobody is helping you and I tend
to be the last to respond.
https://sourceforge.net/p/openocd/mailman/message/36384989/
But the exact problem is not relevant. It is about coordinating
processes with pipes.
1) Create an unnamed pipe, like 'coproc' does, but leaving stdin and
stdout untouched.
mkfifo foo;But the exact problem is not relevant. It is about coordinating
processes with pipes.
1) Create an unnamed pipe, like 'coproc' does, but leaving stdin and
stdout untouched.
2) Start the OpenOCD process as a background job.
openocd --some_option foo &export OCD="$!";
3) Wait for my OpenOCD script to write to the pipe, so that I know that
OpenOCD is now ready to accept connections.
head -c1 foo &OpenOCD is now ready to accept connections.
If OpenOCD dies during initialisation, reading from the pipe will fail,
and the Bash script will exit.
export H="$!";and the Bash script will exit.
sleep 15s;
kill $H;
wait $H;
if [ $H -ne 0 ]; then exit; fi
4) Start GDB in the foreground, which connects to OpenOCD. The Bash
script will continue when GDB exits.
gdb -p $OCD;script will continue when GDB exits.
5) Wait for the OpenOCD background job to finish. We do not want to
leave zombie processes behind.
wait $OCD;leave zombie processes behind.
6) Exit with OpenOCD's exit code.
<snip>exit $?;
I do not have openocd, nor am I aware of how you intend to tell openocd
to access your pipe in order to pipe data so I have not tested all of the
above code. You might have to use a socket instead if you want
bidirectional communication, but I have no experience there so you will
have to wait for someone else to help you.
Even more confusing to me is that you want to run gdb in the foreground
but you also want to wait for the return of openocd!? Both are not
simultaneously possible. Esp. because gdb will prevent openocd from
exiting, or at least that is what happens when my code fouls up. Then I
run the bt command from within gdb.
Sincerely,
David