List Info

Thread: cat-ing commands into gdb (or other program) and terminating cleanly




cat-ing commands into gdb (or other program) and terminating cleanly
country flaguser name
United States
2008-01-15 19:45:13
my context: I'm trying to create a system() command within
my C
program
that invokes gdb, piping it some initial commands and then
turning
control
over to the user to interact with as usual.  I don't want to
use gdb's
command files support because I would prefer to avoid
creating files
from
within this program.

my command: The closest I've come to succeeding is using the
following
command:

     (echo "break main" && cat - ) | gdb
a.out

For example, this sets a breakpoint at main and then turns
control
over to
the console input.

the result: What I'm finding is that when I type
"quit" at the gdb
command,
I have to hit <ENTER> an extra time before I'm
returned to a command
prompt.
I'm guessing that this is because the gdb process has ended
but that
the cat
command doesn't realize that it's gone until I've typed in
my next
line.

my query:  Can anyone verify my theory/suggest another means
of doing
this?
My question seems to be more about "cat" than gdb
per se (which is to
say, I
believe that piping cat into other programs in this way
would generate
similar behavior).  That said, I ultimately want to apply
this to gdb,
so if
there are any gdb-specific tricks (again, not using command
files),
that
would be very helpful.

Thanks very much for any tips,
-Brad Chamberlain

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )