Thread: jdbc and unix signals

jdbc and unix signals

From
Nikk Anderson
Date:

Hi,

I am using the postgres jdbc which was compiled on Solaris as part of the postgres 7.1 installation.

I have a program which runs as a deamon, and connects to postgres for data.  As it is running as a deamon, we have included some signal handling routines.  We are trying to trap HUP (kill -1)  signals, so that the process will not exit when that signal is sent. 

If the program uses the jdbc driver, then the program can not catch the HUP signal - however, if we do NOT use the jdbc at all, then we can trap the signal and deal with it as we wish.

Does the postgres driver catch the signals, thus overiding my attempts to catch them?

Any ideas

Thanks

Nikk Anderson

RE: jdbc and unix signals

From
Nikk Anderson
Date:

Hi,

Peter Eisentraut writes:
>You can't catch signals in Java, because not all systems have signals.
>You might be able to write native methods to do so, but consider
>reconsidering your design.

You can catch OS signals in java, although there are different signals for each OS.  The following packages have signal functionality: sun.misc.Signal, sun.misc.SignalHandler.

I have created test programs which can handle various signals sucessfully - and it is these test programs which work (i.e. catch signals) when no jdbc driver is loaded, and do not when the driver is loaded.

Check out the following url for a discussion about signals.
http://forums.java.sun.com/thread.jsp?forum=37&thread=70586

Cheers

Nikk

Re: jdbc and unix signals

From
Peter Eisentraut
Date:
Nikk Anderson writes:

> Does the postgres driver catch the signals, thus overiding my attempts to
> catch them?

You can't catch signals in Java, because not all systems have signals.
You might be able to write native methods to do so, but consider
reconsidering your design.

--
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter


RE: jdbc and unix signals

From
Peter Eisentraut
Date:
Nikk Anderson writes:

> You can catch OS signals in java, although there are different signals for
> each OS.  The following packages have signal functionality: sun.misc.Signal,
> sun.misc.SignalHandler.

The JDBC driver doesn't use these.

--
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter


Re: jdbc and unix signals

From
Joseph Shraibman
Date:
Run your program using nohup.  In general java programs don't get unix
signals.

> Nikk Anderson wrote:
>
> Hi,
>
> I am using the postgres jdbc which was compiled on Solaris as part of
> the postgres 7.1 installation.
>
> I have a program which runs as a deamon, and connects to postgres for
> data.  As it is running as a deamon, we have included some signal
> handling routines.  We are trying to trap HUP (kill -1)  signals, so
> that the process will not exit when that signal is sent.
>
> If the program uses the jdbc driver, then the program can not catch
> the HUP signal - however, if we do NOT use the jdbc at all, then we
> can trap the signal and deal with it as we wish.
>
> Does the postgres driver catch the signals, thus overiding my attempts
> to catch them?
>
> Any ideas
>
> Thanks
>
> Nikk Anderson

--
Joseph Shraibman
jks@selectacast.net
Increase signal to noise ratio.  http://www.targabot.com