This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Simultaneous open of same file under JNI


The following code demonstrates where System V shared memory
is breaking.

It uses Mumit Khan's JNI example environment.

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <jni.h>
#include "HelloWorld.h"

JNIEXPORT void JNICALL
Java_HelloWorld_displayHelloWorld (JNIEnv *env, jobject obj)
{
  char *home;
  int fd;
  char resp[256];

  printf("Java JNI\n");
  home = getenv ("HOME");
  printf("HOME = %s\n", (home) ? home : "(NULL)");
  printf("Enter any existing file name (complete path) to open\n");
  gets( resp );
  if ( ( fd = open( resp, O_RDWR ) ) == -1 )
	  perror( "open failed" );
  printf("Run again from another window BEFORE Enter to exit\n");
  printf("(Use the same file name to demonstrate problem)\n");
  gets( resp );
  return;
}

Shouldn't this work the same way when called from JNI????
When I run 2 of these to the same file I get Permission denied!
John H. Fralinger         |
SW Contract Engineer      |      1-610-255-5607
Research & Development    |

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]