On 22 Apr 2008 at 16:13,
wo*********@yahoo.com wrote:
I have some a program in which I link a static library. The static
library has a initialize() and uninitialized() function.
Now when I call the initialize function a thread is being started up
and it makes use of the linux timer and start sending signals in a
certain frequency. This is a problem as when I use the getch()
function I see that something is being written continuously to the
console, which is not a satisfactory behavior for my program as in the
program I want to ask the user for certain inputs. I am not familiar
with signals in C but I was wondering if there is anyway to block
those signals.
If you really mean that the thread is sending SIGALRM signals to your
process, then yes, you can block them by changing the disposition for
this signal to ignore:
#include <signal.h>
signal(SIGALRM, SIG_IGN);
(Blocking the signal on a per-thread basis is more complicated: you need
to use sigaction() and alter the signal mask. Ask if you want details of
that.)
However, you probably don't want to do that: it's quite likely that the
library isn't just pointlessly sending signals to your process: it will
have installed a signal handler and be doing something useful in the
handler function. Unfortunately, it also seems to be doing non-useful
things, like writing junk to stdout or stderr. There's not much you can
do about that except looking for a "quiet" or "silent" option you can
give the library.