| delorie.com/archives/browse.cgi | search |
| Mailing-List: | contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm |
| List-Subscribe: | <mailto:cygwin-subscribe AT sourceware DOT cygnus DOT com> |
| List-Archive: | <http://sourceware.cygnus.com/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT sourceware DOT cygnus DOT com> |
| List-Help: | <mailto:cygwin-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs> |
| Sender: | cygwin-owner AT sourceware DOT cygnus DOT com |
| Delivered-To: | mailing list cygwin AT sourceware DOT cygnus DOT com |
| Date: | Tue, 25 Jan 2000 14:07:21 +0300 |
| From: | Pakoulin Konstantin <pakko AT mail DOT ru> |
| X-Mailer: | The Bat! (v1.36) S/N F29DEE5D / Educational |
| Reply-To: | Pakoulin Konstantin <pakko AT mail DOT ru> |
| Organization: | dgap |
| X-Priority: | 3 (Normal) |
| Message-ID: | <3588.000125@mail.ru> |
| To: | cygwin AT sourceware DOT cygnus DOT com |
| Subject: | problem with shared memory under Win9x |
| Mime-Version: | 1.0 |
Hello,
I use shared memory for IPC in my programm, but it doesnt work under
Win9x. I writed test programm that works well under WinNT but doesnt
work under Win9x:
#include <stdio.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define FILENAME "test.bin"
#define FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
int main() {
if ( fork()!=0 ) {
// Parent - server
int fd;
int* mem;
int z = 0;
fd = open( FILENAME , O_RDWR | O_CREAT , FILE_MODE );
write( fd, &z, sizeof(int) );
mem = mmap( NULL, sizeof(int) , PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
close(fd);
printf("par: Waiting!!\n");
while(!(*mem)) ;
// 'mem' equal 0 constantly under Win9x
printf("par: !!!Works Well!!! - %d \n", *mem);
exit(0);
} else {
// Child - client
int fd;
int* mem;
sleep(3);
fd = open( FILENAME , O_RDWR | O_CREAT , FILE_MODE );
mem = mmap( NULL, sizeof(int) , PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
close(fd);
printf("ch: MEM = 3 !!\n");
*mem = 3;
exit(0);
};
}
Do you have any idea ?
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |