is this an signal handler or a alarm ?

L

LeTubs

Hi

I'm not sure if this is correct ...place to post but here goes

This is what i'm trying to do, I want to write a signal / alarm handler
( I don't know which hence the posting here, as once I know the proper
name /useage then I'll use google to try and find out more
information )....
Thus any tips or pointers would be helpful (and I'm using a UNIX variant as
OS)

Many Thanks
David

the (?) means I'm not sure if I need the variable or not...

xxxxxxx( &MyTimeFunction, (?)(void *)SleepCounter );

do_some_other_work(......)
..
..
..
/* Check to see if the sleep counter has been set (ie it has
waited a specific time or timeout period
*/
xxxxxxx( SleepCounter );

void * MyTimeFunction( void * arg ){

int MySleepCounter = (int) arg;
for ( i = 0; i < SOME_SYSTEM_COUNTER; i++ ){}

/* Not sure on this bit also but want to set a value of 1
to denote the sleep time has been set
*/
SleepCounter = 1;
}
 
E

E. Robert Tisdale

LeTubs said:
I'm not sure if this is correct ...place to post but here goes

This is what I'm trying to do, I want to write a signal/alarm handler
(I don't know which hence the posting here,
as once I know the proper name/useage
then I'll use google to try and find out more information )....
Thus any tips or pointers would be helpful
(and I'm using a UNIX variant as OS)

SIGNAL(2) Linux Programmer’s Manual SIGNAL(2)

NAME
signal - ANSI C signal handling

SYNOPSIS
#include <signal.h>

typedef void (*sighandler_t)(int);

sighandler_t signal(int signum, sighandler_t handler);

DESCRIPTION
The signal() system call installs a new signal handler
for the signal with number signum.
The signal handler is set to sighandler which may be
a user specified function, or either SIG_IGN or SIG_DFL.

Upon arrival of a signal with number signum,
the following happens.
If the corresponding handler is set to SIG_IGN,
then the signal is ignored. If the handler is set to SIG_DFL,
then the default action associated to the signal
(see signal(7)) occurs. Finally,
if the handler is set to a function sighandler,
then first either the handler is reset to SIG_DFL
or an implementation-dependent blocking of the signal
is performed and next sighandler is called with argument signum.

Using a signal handler function for a signal
is called "catching the signal".
The signals SIGKILL and SIGSTOP cannot be caught or ignored.

RETURN VALUE
The signal() function returns
the previous value of the signal handler, or SIG_ERR on error.

.
.
.

CONFORMING TO
ANSI C

SEE ALSO
kill(1), kill(2), killpg(2), pause(2), raise(3),
sigaction(2), signal(7), sigsetops(3), sigvec(2), alarm(2)

Linux 2.2 2000-04-28 SIGNAL(2)
 

Ask a Question

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.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top