This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: Pipe question
- From: Michael Elizabeth Chastain <mec at shout dot net>
- To: a2782 at dis dot ulpgc dot es
- Cc: gdb at sources dot redhat dot com
- Date: Wed, 4 Dec 2002 10:44:42 -0600
- Subject: Re: Pipe question
Good morning,
> But when I close the program, I only write \"quit\\n\" to togdb[1]. This
> causes that the program doesn\'t end properly (GDB, which is the child
> process, ends well). I have to go and type \"kill\" in a console.
Try running gdb directly and starting up an inferior process (child process).
Then type "quit <CR>" on the command line and you will see what is happening:
(gdb) quit
The program is running. Exit anyway? (y or n)
At this point gdb is still running and the inferior process still exists.
Your program is probably closing the pipe and killing gdb at this point
and that leaves the inferior process.
> Could anybody tell me what instructions I have to put in the end of the
> program in order to finish it succesfully (without kill)?
Write a "y\n" down the pipe. Then gdb will take care of killing the
inferior process.
Note that gdb will ask the question only if it has an inferior process running,
so your program has to parse gdb's output to see if it is asking the
question. Or you may know for sure that there is always an inferior process.
Or you could just slam a "y\n" down the pipe unconditionally; if gdb does not
ask the question, it won't be alive to read the "y\n". But that would
be crude.
Hope this helps,
Michael C