Mail Archives: cygwin/2001/04/13/17:53:00
cygwin 1.1.8 mmap()/fork() bug is still not fixed. Works fine under
cygwin 1.1.7.
The following C++ code breaks under cygwin 1.1.8-2 and all current
development snapshots...
#include <iostream.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/mman.h>
main(int argc, char **argv)
{
if( argc < 2 ) {
cerr << "Usage: bug filename" << endl;
exit(1);
}
int file = open(argv[1], O_RDONLY);
if (file == -1) {
cerr << "can't open data file " << argv[1] << endl;
exit(-1);
}
struct stat statbuf;
if (fstat(file, &statbuf) < 0) {
cerr << "fstat failed" << endl;
exit(-1);
}
int len = statbuf.st_size;
if (!len) {
cerr << "len is 0" << endl;
exit(-1);
}
char *buf = mmap(NULL, len, PROT_READ, MAP_SHARED, file, 0);
if (!buf) {
cerr << "mmap() failed" << endl;
exit(-1);
}
close(file);
fork();
cerr << dec << len << ' ' << hex << (short*)buf << endl;
munmap(buf, len);
cerr << "OK" << endl;
exit(0);
}
--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple
- Raw text -