* Re: Pipe question
@ 2002-12-04 8:45 Michael Elizabeth Chastain
2002-12-04 13:27 ` Pipe question (mmm) a2782
0 siblings, 1 reply; 6+ messages in thread
From: Michael Elizabeth Chastain @ 2002-12-04 8:45 UTC (permalink / raw)
To: a2782; +Cc: gdb
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Pipe question (mmm)
2002-12-04 8:45 Pipe question Michael Elizabeth Chastain
@ 2002-12-04 13:27 ` a2782
2002-12-05 10:56 ` Stanley Gambarin
[not found] ` <02Dec5.103736pst.119043@gateway.apogee.com>
0 siblings, 2 replies; 6+ messages in thread
From: a2782 @ 2002-12-04 13:27 UTC (permalink / raw)
To: gdb
Thanks again to Eli (I have removed the bug of strcat and the constant
string) and Michael C for their effort.
It\'s important to realize that gdb asks to confirm in several points of
its execution (I will consider it from now). But I was using a very
short code and this prompt didn\'t appear (and, as I said, GDB is ending
properly). I wonder if it can be a problem with my development GUI
(Kylix 3.0 Open Edition) or something I may be missing. Well, if anyone
knows something new, don\'t hesitate to help me!
Ciao!
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Pipe question (mmm)
2002-12-04 13:27 ` Pipe question (mmm) a2782
@ 2002-12-05 10:56 ` Stanley Gambarin
[not found] ` <02Dec5.103736pst.119043@gateway.apogee.com>
1 sibling, 0 replies; 6+ messages in thread
From: Stanley Gambarin @ 2002-12-05 10:56 UTC (permalink / raw)
To: a2782, gdb
it is unlikely that sending \"quit\\n\" down to GDB will work,
since it will take some time for GDB to reply to 'quit' command.
The solution that work for me (in a very similar situation), is to
issue following commands:
> set confirm off
> quit
The 'confirm' command is used to confirm dangerous operations;
disabling it will tell GDB to just go ahead and quit (killing inferior, if
there is one present).
Hope that helps,
-- stanley
----- Original Message -----
From: <a2782@dis.ulpgc.es>
To: <gdb@sources.redhat.com>
Sent: Wednesday, December 04, 2002 2:25 PM
Subject: Re: Pipe question (mmm)
> Thanks again to Eli (I have removed the bug of strcat and the constant
> string) and Michael C for their effort.
>
> It\'s important to realize that gdb asks to confirm in several points of
> its execution (I will consider it from now). But I was using a very
> short code and this prompt didn\'t appear (and, as I said, GDB is ending
> properly). I wonder if it can be a problem with my development GUI
> (Kylix 3.0 Open Edition) or something I may be missing. Well, if anyone
> knows something new, don\'t hesitate to help me!
>
> Ciao!
>
^ permalink raw reply [flat|nested] 6+ messages in thread[parent not found: <02Dec5.103736pst.119043@gateway.apogee.com>]
* Re: Pipe question (mmm)
[not found] ` <02Dec5.103736pst.119043@gateway.apogee.com>
@ 2002-12-06 8:58 ` a2782
0 siblings, 0 replies; 6+ messages in thread
From: a2782 @ 2002-12-06 8:58 UTC (permalink / raw)
To: gdb
That\'s a good idea, Stanley. I have thought about it, but I didn\'t know
the command.
Mensaje citado por: Stanley Gambarin <stanley@apogee.com>:
> it is unlikely that sending \\\"quit\\\\n\\\" down to GDB will work,
> since it will take some time for GDB to reply to \'quit\' command.
> The solution that work for me (in a very similar situation), is to
> issue following commands:
>
> > set confirm off
> > quit
>
> The \'confirm\' command is used to confirm dangerous operations;
> disabling it will tell GDB to just go ahead and quit (killing
inferior, if
> there is one present).
>
> Hope that helps,
>
> -- stanley
>
> ----- Original Message -----
> From: <a2782@dis.ulpgc.es>
> To: <gdb@sources.redhat.com>
> Sent: Wednesday, December 04, 2002 2:25 PM
> Subject: Re: Pipe question (mmm)
>
>
> > Thanks again to Eli (I have removed the bug of strcat and the
constant
> > string) and Michael C for their effort.
> >
> > It\\\'s important to realize that gdb asks to confirm in several
points of
> > its execution (I will consider it from now). But I was using a very
> > short code and this prompt didn\\\'t appear (and, as I said, GDB is
ending
> > properly). I wonder if it can be a problem with my development GUI
> > (Kylix 3.0 Open Edition) or something I may be missing. Well, if
anyone
> > knows something new, don\\\'t hesitate to help me!
> >
> > Ciao!
> >
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Pipe question
@ 2002-12-04 5:39 a2782
2002-12-04 8:18 ` Eli Zaretskii
0 siblings, 1 reply; 6+ messages in thread
From: a2782 @ 2002-12-04 5:39 UTC (permalink / raw)
To: gdb
Hi to all!
First, I want to thank Eli Zaretskii, Jim Blandy, Kris Warkentin, Keith
Seitz and Joel Brobecker for their advices about communication with GDB.
Now, a question. I\'m doing this:
pipe(togdb); pipe(fromgdb);
if (fork() != 0)
{
close(togdb[0]);
close(fromgdb[1]);
}
else
{
/* This is necessary for my GUI */
int Max = sysconf(_SC_OPEN_MAX);
for (int i=STDERR_FILENO+1;i<Max;i++)
fcntl(i, F_SETFD, FD_CLOEXEC);
close(togdb[1]);
dup2(togdb[0],0);
close(fromgdb[0]);
dup2(fromgdb[1],1);
system(strcat(\"gdb --quiet -f \",executable));
}
When I want to give GDB a command, I write in togdb[1]; when I want to
parse GDB output, I read from fromgdb[0]. All is working. (Note: system
() is exec()).
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. Could
anybody tell me what instructions I have to put in the end of the
program in order to finish it succesfully (without kill)? I suppose
it\'s something related with the pipes...
Thanks in advance.
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Pipe question
2002-12-04 5:39 Pipe question a2782
@ 2002-12-04 8:18 ` Eli Zaretskii
0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2002-12-04 8:18 UTC (permalink / raw)
To: a2782; +Cc: gdb
> Date: Wed, 4 Dec 2002 14:36:36 GMT
> From: a2782@dis.ulpgc.es
>
> system(strcat(\"gdb --quiet -f \",executable));
I hope this is not your actual code: you cannot strcat onto a
constant string. It's a bug.
> 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. Could
> anybody tell me what instructions I have to put in the end of the
> program in order to finish it succesfully (without kill)?
When you give GDB the `quit' command, it asks whether to kill the
program being debugged; you need to respond with "yes". So something
like "quit\nyes\n" should do the trick (but I didn't actually try
this, so I might miss something).
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2002-12-06 16:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-04 8:45 Pipe question Michael Elizabeth Chastain
2002-12-04 13:27 ` Pipe question (mmm) a2782
2002-12-05 10:56 ` Stanley Gambarin
[not found] ` <02Dec5.103736pst.119043@gateway.apogee.com>
2002-12-06 8:58 ` a2782
-- strict thread matches above, loose matches on Subject: below --
2002-12-04 5:39 Pipe question a2782
2002-12-04 8:18 ` Eli Zaretskii
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox