Sending information with a Signal in Linux
问题 When sending a signal from one process to another, I also want to send a value of type long . Is that possible? I am using SIGUSR1. 回答1: Sure you can, but you'll have to send it with sigqueue(2) instead of kill(2) . And you can send an int or a sival_ptr . union sigval { int sival_int; void *sival_ptr; }; Establish the handler struct sigaction sa; sigemptyset(&sa.sa_mask); sa.sa_sigaction = handler; sa.sa_flags = SA_SIGINFO; /* Important. */ sigaction(SIGUSR1, &sa, NULL); The handler for a