So iam developing a program that when receive a signal kill -SIGUSR1 PID
, need to output to stdout the following line:
2020-10-09T18:01:27+01:00
, and this is the time, when programm was launched, so I need to get this time when the signal is received! I am using siginfo
I dont need to know how to print, I need to know how to get the time when the program was launched!
act.sa_sigaction = signalManagement;
sigemptyset(&act.sa_mask);
act.sa_flags |= SA_SIGINFO;
act.sa_flags |= SA_RESTART;
if (sigaction(SIGUSR1 , &act, NULL) < 0){
ERROR(1, "sigaction - SIGUSR1 ");
}
and my signal function is:
void signalManagement(int sig, siginfo_t *siginfo, void *context)
{
(void)context;
int aux;
aux = errno;
if(sig == SIGUSR1 ){
//* I need code where to show the output "2020-10-09T18:01:27+01:00", example when programm was launched
}
errno = aux;
}