This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: gcj: SignalListener, process pid, ...
Tom Tromey writes:
> >>>>> "Erik" == Erik Poupaert <erik.poupaert@freestyler-toolkit.org> writes:
>
> Erik> For long-running processes (serverside programs) on linux, I
> Erik> need to "signal" them with -HUP to reread their config files,
> Erik> and "-TERM" to stop operating. How can I respond to signals in
> Erik> gcj? I mean, is there a class like "SignalListener" anywhere?
> Erik> Do I need to wrap something with CNI? Has anybody done that
> Erik> already?
>
> I don't know of any existing code to do it. You'd have to write it
> yourself.
This is tricky because an asynchronous signal handler can't do
anything that might try to acquire a lock because it might block.
That means that notify() couldn't be directly used. I guess the
handler could set a static variable somewhere. That's probably
adequate for this particular job.
> Erik> Has anybody already created a CNI-based posix-oriented library
> Erik> that makes the classical unix concepts available in gcj
> Erik> (environment vars, signals, pid, essential areas in libc,...). I
> Erik> wonder how you can write decent server programs for unix/linux,
> Erik> without it?
>
> People have talked about POSIX wrappers for java (and libgcj), but I
> don't recall seeing an implementation. There's a thread about this in
> our archives (which you participated in :-), e.g.:
>
> http://gcc.gnu.org/ml/java/2003-04/msg00441.html
Surely it's a simple matter to write native methods -- that's what
JNI/CNI is for. If this is a server for POSIX, who will care that
it's not 100% Pure Java (TM) ?
Andrew.