Скачиваний:
17
Добавлен:
01.05.2014
Размер:
740 б
Скачать
		#include <stdio.h>
		#include <unistd.h>
		#include <signal.h>
		#define   INTERVAL   5


		void callme( int sig_no ) 

		{ 

					alarm( INTERVAL );

					/* do scheduled tasks */

		}



		int main()

		{

				struct sigaction  action;



				sigemptyset(&action.sa_mask);

#ifdef SOLARIS_25
				action.sa_handler = (void (*)(int))callme;
#else
				action.sa_handler = (void (*)())callme;
#endif

				action.sa_flags = SA_RESTART;

				if ( sigaction( SIGALRM,&action,0 )==-1 ) 				{

					perror( "sigaction");

					return 1;

				}

				if (alarm( INTERVAL ) == -1)

					perror("alarm" );

				else while( 1 ) 			{

					/* do normal operation */

				}

				return 0;

			}
Соседние файлы в папке ch9