This is the mail archive of the cygwin@cygwin.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]
Other format: [Raw text]

Using forking cygwin programmes with JNI


Hi there,

I've got a Java programme which needs to read and write to the stdin and
stdout of a native programme. On Linux, I've used /dev/ptmx and then forked
and exec'd to give myself a single file descriptor which I can use to both
read and write to the child process. I would like to do the same on Windows
with Cygwin, but fork fails with the error message 'Fork failed because of
Resource temporarily unavailable' when called via JNI. The same code called
outside of the JVM works fine. On Linux it works both inside and outside the
JVM.

I've attached a simple programme to demonstrate this. If you follow these
steps, you can re-produce the problem:

gcc -shared HelloWorld.c -o hello.dll
javac HelloWorld.java
java HelloWorld

For me, using Cygwin 1.3.22-1 and Sun's JDK version 1.4.1_03-b02, I get the
following output:

C:\CYGWIN\HOME\ADMINI~1\JNI>java HelloWorld
Usage: java [-options] class [args...]
           (to execute a class)
   or  java -jar [-options] jarfile [args...]
           (to execute a jar file)

where options include:

<snipped several Java options>

    -dsa | -disablesystemassertions
                  disable system assertions
    101 [main] ? 2044 sync_with_child: child 1420(0x3F4) died before
initialization with status code 0x1
    436 [main] ? 2044 sync_with_child: *** child state waiting for longjmp
Fork failed because of Resource temporarily unavailable

I've tried various methods of working around this problem using windows'
'CreateProcess' API method and lots of other stuff, but nothing works as
well as pseudo terminal/fork/exec does on Linux. Has anyone got any
suggestions?

Thank you,

Martin


IMPORTANT NOTICE:
This e-mail and any attachment to it is intended only to be read or used by
the named addressee.  It is confidential and may contain legally privileged
information.  No confidentiality or privilege is waived or lost by any
mistaken transmission to you.  If you receive this e-mail in error, please
immediately delete it from your system and notify the sender.  You must not
disclose, copy or use any part of this e-mail if you are not the intended
recipient.  The RTA is not responsible for any unauthorised alterations to
this e-mail or attachment to it.  
      

Attachment: HelloWorld.c
Description: Binary data

Attachment: HelloWorld.h
Description: Binary data

Attachment: HelloWorld.java
Description: Binary data

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

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