mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-03 10:05:29 +00:00
* fix error in usability msg * make a test more deterministic (Philippe Waroquiers, philippe.waroquiers@skynet.be). Bug 214909 comment 107. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11835
39 lines
715 B
C
39 lines
715 B
C
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <errno.h>
|
|
#include <unistd.h>
|
|
#include <sys/wait.h>
|
|
int main()
|
|
{
|
|
int mem = 0, pid;
|
|
pid = fork();
|
|
if (pid == -1) {
|
|
mem = 1;
|
|
perror("fork");
|
|
exit(1);
|
|
}
|
|
|
|
if (pid == 0) {
|
|
int burn;
|
|
for (burn = 0; burn < 100000; burn++) /* burncpu */__asm__ __volatile("":::"memory") ;
|
|
if (mem == 0)
|
|
exit(0);
|
|
else
|
|
exit(1);
|
|
} else {
|
|
int ret;
|
|
int status;
|
|
while((ret = waitpid(pid, &status, 0)) != pid) {
|
|
if (errno != EINTR) {
|
|
perror("waitpid");
|
|
exit(1);
|
|
}
|
|
}
|
|
mem = status;
|
|
}
|
|
if (mem == 0)
|
|
printf("mem is zero\n");
|
|
|
|
return 0;
|
|
}
|