* [Qemu-devel] [PATH] gdbstub: fix gdbserver_fork
@ 2009-01-06 18:02 Laurent Desnogues
0 siblings, 0 replies; only message in thread
From: Laurent Desnogues @ 2009-01-06 18:02 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 280 bytes --]
Hello,
as reported by Martin Mohring fork doesn't work with NPTL.
A fix is attached that makes the also attached test run
(tested with ARM CodeSourcery 2008q3 on an x86_64
Fedora Core with kernel 2.6.23).
Laurent
Signed-off-by: Laurent Desnogues <laurent.desnogues@gmail.com>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fork.patch --]
[-- Type: text/x-patch; name=fork.patch, Size: 352 bytes --]
Index: gdbstub.c
===================================================================
--- gdbstub.c (revision 6146)
+++ gdbstub.c (working copy)
@@ -2225,7 +2225,7 @@
void gdbserver_fork(CPUState *env)
{
GDBState *s = gdbserver_state;
- if (s->fd < 0)
+ if (gdbserver_fd < 0 || s->fd < 0)
return;
close(s->fd);
s->fd = -1;
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: testfork.c --]
[-- Type: text/x-csrc; name=testfork.c, Size: 505 bytes --]
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <wait.h>
static void test_fork(void)
{
pid_t id;
id = fork();
if (id == 0) {
printf("child\n");
exit(0);
} else if (id == -1) {
perror("Fork fail");
exit(-1);
} else {
int status;
waitpid(id, &status, 0);
printf("Parent: done %d\n", status);
exit(0);
}
}
int main(int argc, char **argv)
{
test_fork();
return 0;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-01-06 18:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-06 18:02 [Qemu-devel] [PATH] gdbstub: fix gdbserver_fork Laurent Desnogues
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.