Below is a program which demonstrates the problem.  On a Sparc 4,
the program exits immediately and 5 seconds later "Baz!" is printed.
On the Redhat 5.x systems I've been trying it on I only get the following:
fenris@cow:~[0]$ ./foo
mmap error! Invalid argument
I've tried various sizes (4096, 65536, 10, etc) but none seem to work.
Any suggestions?
#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
int main(void)
{
	int fd;
	char *area;
	fd = open("/dev/zero", O_RDWR);
	if (fd < 0) {
		printf("open error! %s\n", strerror(errno));
		return -1;
	}
	area = mmap(NULL, 10, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
	if (area == MAP_FAILED) {
		printf("mmap error! %s\n", strerror(errno));
		return -1;
	}
	close(fd);
	if (fork()) {
		strcpy(area, "Baz!\n");
		_exit(0);
	} else {
		sleep(5);
		printf("%s", area);
		exit(0);
	}
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/