ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm pretty new to this kind of programming and need some help:
I generate an interrupt on raspbian using struct itimerval for the timer and struct sigaction (see https://man7.org/linux/man-pages/man2/sigaction.2.html) for the signal generating an interrupt. The member sigaction.sa_handler seems to be a pointer to a function, some kind of interrupt service routine like used on Arduinos. The function needs one integer as input and I wonder what this is. Can anyone tell me if there is a list or something to determine the exact source of the interrupt?
In 'struct sigaction' you can use either 'sa_handler' or 'sa_sigaction', but not both of them. Also you have to use flag SA_SIGINFO in field sa_flags accordingly.
Example1:
Code:
static void handler (int signo) {
[I only have 'signo']
}
int main (void) {
struct sigaction siga;
memset (&siga, 0, sizeof siga);
siga.sa_handler= handler;
sigaction (SIGsomething, &siga, NULL);
...
}
Example2:
Code:
static void handler3 (int signo, siginfo_t *info, void *ucontext) {
[I have 'signo' and 'info', also 'ucontext' whatever it is]
}
int main (void) {
struct sigaction siga;
memset (&siga, 0, sizeof siga);
siga.sa_sigaction= handler3;
siga.sa_flags |= SA_SIGINFO;
sigaction (SIGsomething, &siga, NULL);
...
}
The int passed as an argument to a signal handler is the signal number (i.e. type) that caused it to be invoked. If a signal handler is only attached to a single signal, then it's pretty much redundant information.
The sigaction(3) man-page documents this, and you can find the signal numbers on signal(7).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.