S
Steven Simpson
CtrlCRunner ctrl = new CtrlCRunner();
ctrl.installCtrlC(
new Runnable() {
public void run() {
/* do nothing ! */
}
}
);
What class is this? Is it specified somewhere?
Cheers!
CtrlCRunner ctrl = new CtrlCRunner();
ctrl.installCtrlC(
new Runnable() {
public void run() {
/* do nothing ! */
}
}
);
Arne said:If what you want is not in the docs, then it
is not broken as you claim.
I guess your are subject to the same brainwash like
the subjects in "The Emperor's New Clothes". I even
don't feel pitty for you.
Steven said:What class is this? Is it specified somewhere?
Jan said:So this is what is broken here. It contaminates
any sensible use of shutdown hooks as described
here in the case of Windows:
http://docs.oracle.com/javase/1.4.2...untime.html#addShutdownHook(java.lang.Thread)
Patricia said:I've found that general strategy useful for dealing with other
specialized activities that are not directly supported in Java. For
example, I needed some intense matrix manipulation that was not
supported well in any library I found, but was trivial in Matlab. The
combination of a Java program with a very small Matlab program did
everything I needed.
Joshua said:My recommendations:
1. Find some way to not need this.
2. Write a JNI library that implements what you want to do.
3. Use another programming language.
If you're still not happy, then I suspect you're probably in the wrong
profession.
Since the whole application works fine on Linux and Mac,
and it is entirely written with Java, I am quite happy
with Java. It is only that there is a small obstacle with
Windows.
I am quite astonished that from such a small obstacle you
more or less suggest suicide. I guess you lack perseverance
and discipline.
Its simply broken because of the following
chain of reasoning.
- InputStream/OutputStream are supposed
to be blocking IO in contrast to NIO.
- When a shutdown sequence is initiated
no InputStream/OutputStream is killed
they remain blocking in case they were
already blocking.
so that the shutdown hooks can gracefully
terminate their service. For example
a goodbye sequence with a web server, etc..
- SIGINT when available, by default
initiates a shutdown sequence.
- The Windows behaviour for CONIN$ violates
the above, since during SIGINT the
CONIN$ becomes non-blocking in that
it returns EOF.
So this is what is broken here. It contaminates
any sensible use of shutdown hooks as described
here in the case of Windows:
http://docs.oracle.com/javase/1.4.2...untime.html#addShutdownHook(java.lang.Thread)
Using a loosely coupled solution (i.e. two processes or
so) is only second priority. First priority is a fully
integrated solution. Something along:
public class FileInputStreamFix extends FileInputStream;
I alreay tried subclassing FileInputStream. Works fine.
For example I experimented with a
public class FileInputStreamTest1 extends FileInputStream {
public void close() throws IOException {
/* do nothing */
}
}
By the above you get a file input stream that cannot be
closed. I noticed that some JNA solutions bundle a DLL
inside the resources of the application. At runtime they
then unpack/download this resource to a local location
and invoke loadLibrary().
So I guess a fully integrated solution should be possible
that carries its own Windows specific code.
Its a custom made wrapper for Signal & SignalHandler.
In version 1 of the above class I used the package
sun.misc.*. In version 2 of the above class I
used reflection i.e. Proxy class etc.. It will
noop when sun.misc.Signal is not present.
See for example:
http://stackoverflow.com/questions/2783595/dynamic-reflective-signalhandler-in-java
It is not portable, since sun.misc.* is not official
part of the JDK. But testing showed that the reflection
stuff works fine for the cases when sun.misc.* is
present.
The reflection thing is also useful when the code by
chance lands in an applet. Some verifier murne the use
of sun.misc.* inside an applet, even if during the
execution of the applet the package is not called.
There is some post on the web where Oracle/Sun claims
they never said they WILL remove sun.misc.*, they only
said they MIGHT remove sun.misc.*.
Arne said:Joshua would have had implemented one of the proposed
solutions by know and moved on to next problem.
Arne said:It is a rather risky business to rely on such
features.
Arne said:It is just something you have invented.
Jan said:Although the API would allow very fine non-
blocking, for example via throwing Interrupted-
IOException, but most of the piggy pack readers/
writes don't support it properly.
How does Joshua then do it?
InputStream/OutputStream are blocking I/O
for the standard I/O resources delivered
by the standard library.
Do you need proof?
I was faster, I implemented already Gabriel Genellina
solution (see Link in my very first post) a couple
of days ago.
But maybe Joshua could share his solution, so that
we could compare notes.
Jan said:So I opted for a Gabriel Genellina solution with a
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.