This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Always print "Detaching after fork from child..."
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Sergio Durigan Junior <sergiodj at redhat dot com>
- Cc: GDB Patches <gdb-patches at sourceware dot org>
- Date: Wed, 24 Jan 2018 21:43:39 +0100
- Subject: Re: [PATCH] Always print "Detaching after fork from child..."
- Authentication-results: sourceware.org; auth=none
- References: <20180124194714.26222-1-sergiodj@redhat.com>
On Wed, 24 Jan 2018 20:47:14 +0100, Sergio Durigan Junior wrote:
> https://bugzilla.redhat.com/show_bug.cgi?id=235197
As a justification for this patch:
------------------------------------------------------------------------------
cat >fork2.c <<EOH
#include <unistd.h>
#include <stdio.h>
static void printit(void) {
puts("printed");
}
int main(void) {
if (!fork()) printit();
return 0;
}
EOH
gcc -o fork2 fork2.c -Wall -g
gdb -q ./fork2
(gdb) b printit
Breakpoint 1 at 0x40052b: file fork2.c, line 4.
(gdb) r
Starting program: /quad/home/jkratoch/t/fork2
printed
[Inferior 1 (process 15812) exited normally]
(gdb) q
------------------------------------------------------------------------------
As the GDB user does not expect the program could do any forks s/he is
confused the breakpoint did not get hit and assumes GDB is just broken.
But then I cannot say this patch is too great, it produces many uninteresting
Detaching after fork from child process 24905.
messages rather just annoying in most cases. So nowadays I feel the message
is more an excuse how to show it is user's fault s/he did not read it.
But I think nobody reads them as there are too many such messages.
I believe the right fix would be to make "set detach-on-fork off" the default.
But that is sure a new can of worms I do not want to speculate about.
Jan