delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/04/13/17:53:00

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-ID: <3AD7732C.F448C20A@cfa.harvard.edu>
Date: Fri, 13 Apr 2001 17:44:12 -0400
From: William Joye <wjoye AT cfa DOT harvard DOT edu>
X-Mailer: Mozilla 4.75 [en] (WinNT; U)
X-Accept-Language: en
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
CC: wjoye AT cfa DOT harvard DOT edu
Subject: cygwin 1.1.8 mmap()/fork() bug still not fixed

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019