# Include <unistd. h>
# Include <stdio. h>
# Include <signal. h>
# Include <sys/time. h>
Typedef struct _ delete_file_para_str
{
Int intdays;
Char * strpaths;
} Deletefileparastr;
// Sigaction = Signal
Deletefileparastr strpara = {9876, "/root/test |/var/Data "};
Void handle (int s, siginfo_t * info, void * D)
{
Deletefileparastr * punionpara = (deletefileparastr *) Info-> si_ptr;
Printf ("SIGUSR1 handle parameter: % d, % s \ n", punionpara-> intdays, punionpara-> strpaths );
}
Void handle_timer (int s)
{
Printf ("handle_timer begin... \ n ");
Union sigval val;
Val. sival_ptr = & strpara;
Sigqueue (getpid (), SIGUSR1, Val );
}
Main ()
{
Struct sigaction act = {};
Act./* 2 */sa_sigaction = handle; // use non-traditional processing functions
Sigemptyset (& (Act. sa_mask ));
Act. sa_flags =/* 1 */sa_siginfo; // 0 indicates that the traditional processing function is used.
// Sa_siginfo indicates that the data transmission processing function is used.
Sigaction (SIGUSR1, & act, 0); // register the signal and signal behavior
/* Timer operation */
Struct itimerval Val = {};
Signal (sigalrm, handle_timer );
Val. it_interval. TV _sec = 2;
Val. it_value. TV _usec = 1;
Setitimer (itimer_real, & Val, 0 );
While (1 );
}
/* Output result
Handle_timer begin...
SIGUSR1 handle parameter: 9876,/root/test |/var/Data
Handle_timer begin...
SIGUSR1 handle parameter: 9876,/root/test |/var/Data
Handle_timer begin...
SIGUSR1 handle parameter: 9876,/root/test |/var/Data
Handle_timer begin...
SIGUSR1 handle parameter: 9876,/root/test |/var/Data
Handle_timer begin...
SIGUSR1 handle parameter: 9876,/root/test |/var/Data
*/