This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]