Using forking cygwin programmes with JNI

GALLWEY Martin Martin_GALLWEY@rta.nsw.gov.au
Wed Aug 6 10:08:00 GMT 2003


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.  
      

-------------- next part --------------
A non-text attachment was scrubbed...
Name: HelloWorld.c
Type: application/octet-stream
Size: 406 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20030806/a94c9b52/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: HelloWorld.h
Type: application/octet-stream
Size: 401 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20030806/a94c9b52/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: HelloWorld.java
Type: application/octet-stream
Size: 478 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20030806/a94c9b52/attachment-0002.obj>
-------------- next part --------------
--
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/


More information about the Cygwin mailing list