/* Example of using sigaction() to setup a signal handler with 3 arguments
* including siginfo_t.
*/
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
static void hdl (int sig, siginfo_t *siginfo, void *context)
{
printf ("Sending PID: %ld, UID: %ld
",
(long)siginfo->si_pid, (long)siginfo->si_uid);
}
int main (int argc, char *argv[])
{
struct sigaction act;
memset (&act, ' ', sizeof(act));
/* Use the sa_sigaction field because the handles has two additional parameters */
act.sa_sigaction = &hdl;
/* The SA_SIGINFO flag tells sigaction() to use the sa_sigaction field, not sa_handler. */
act.sa_flags = SA_SIGINFO;
if (sigaction(SIGTERM, &act, NULL) < 0) {
perror ("sigaction");
return 1;
}
while (1)
sleep (10);
return 0;
}
Code Example |
---|
C :: remove element from np array |
C :: thread in c |
C :: successeur d’un entier donné |
C :: for loop c |
C :: print ascii value in c |
C :: how to read space separated words in c |
C :: C how to find substring in string |
C :: c program |
C :: console log observable data |
C :: string if statements c |
C :: selection sort in c |
C :: c check if character is a digit |
C :: pg_restore: error: input file appears to be a text format dump. Please use psql. |
C :: char array to int c |
C :: function for calculate the average and standard deviation of table |
C :: convert int to string c |
C :: pyramid using c |
C :: C Passing Pointers to Functions |
C :: hello word in c |
C :: lateinit kotlin |
C :: malloc contiguous 2d array |
C :: pointer to function c |
C :: how compress string in c |
C :: calculate median |
C :: c program to implement mv command |
C :: ex: C hello world |
C :: sqrt function in c |
C :: c conventions |
C :: pointer c |
C :: predefined macros |