mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-06 11:41:34 +00:00
Patch that fixes the problem reported by Christian Borntraeger.
The problem was created by keeping the shared memory mapped file opened
without reason till the process does an exec.
In case of a chain of forked processes (without exec), the range of safe_fd
reserved for Valgrind own usage becomes exhausted.
* coregrind/m_gdbserver/remote-utils.c :
do not VG_(safe_fd) shared_mem_fd (as it is now closed directly)
close shared_mem_fd once file is mmap-ed and written.
* gdbserver_tests/nlfork_chain.stderr.exp,nlfork_chain.vgtest,
fork_chain.c,nlfork_chain.stdout.exp:
new files
* gdbserver_tests/Makefile.am:
modified for new nlfork_chain test
(patch from #214909 c 103,
Philippe Waroquiers, philippe.waroquiers@skynet.be)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11818
38 lines
623 B
C
38 lines
623 B
C
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <errno.h>
|
|
#include <unistd.h>
|
|
#include <sys/wait.h>
|
|
void fork_chain(int level)
|
|
{
|
|
int pid;
|
|
|
|
printf ("forking level %d\n", level);
|
|
fflush (stdout);
|
|
pid = fork();
|
|
if (pid == -1) {
|
|
perror("fork");
|
|
exit(1);
|
|
}
|
|
|
|
if (pid == 0) {
|
|
if (level > 0) {
|
|
fork_chain (level - 1);
|
|
}
|
|
} else {
|
|
int ret;
|
|
int status;
|
|
while((ret = waitpid(pid, &status, 0)) != pid) {
|
|
if (errno != EINTR) {
|
|
perror("waitpid");
|
|
exit(1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
int main()
|
|
{
|
|
fork_chain (20);
|
|
return 0;
|
|
}
|