I'm writing a program which needs to do the following things:
1. Open a connection to a message-passing system which communicates
via SysV IPC.
2. Invoke a JVM and instantiate some GUI objects (i.e. the AWT not-
on-mail-thread rule applies).
3. Listen for messages on IPC, and convert them into appropriate
Java method calls (and do them).
4. Cleanly disconnect from the IPC system when the program quits.
I started with the simpleJavaLauncher sample program and have
something which performs requirements 1-3. However, it does not
disconnect on exit.
So, I've been looking into how I can capture the "quit" event and
write an appropriate handler. Thus far, I've found the Carbon
function "InstallApplicationEventHandler", and have had some
success in seeing the kHICommandQuit message in a separate test
program. However, this seems to require the Carbon run loop invoked
by "RunApplicationEventLoop", rather than CoreFoundation's
CFRunLoopRun. Unfortunately, if I don't use CFRunLoopRun in main,
my program hangs when the secondary thread tries to instantiate the
first Java GUI object.
Is there a way that I can capture the Quit message in the
CFRunLoop, or invoke the JVM with the Carbon loop? (Or even better,
does cmd-Q/Quit menu item generate a BSD signal I can capture
before my program dies?)
I've done lots of Java programming and lots of Unix programming,
but this is my first foray into Carbon, so please be gentle ;).
Perhaps Runtime.addShutdownHook(Thread) may help, it runs when the VM
is asked to shutdown. AFAIK, nothing done in the UI ever sends
signals to the BSD layer.
Cheers,
Mike Swingler
Java Frameworks Engineer
Apple Computer
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden