Questions tagged [sigaction]

The sigaction() system call is used to change the action taken by a process on receipt of a specific signal.

The sigaction() function allows the calling process to examine and/or specify the action to be associated with a specific signal. In computing, sigaction is a function API defined by POSIX to give the programmer access to what should be a program's behavior when receiving specific OS

106 questions
0
votes
1 answer

When catching SIGSEGV from within, how to known the kind of invalid access involved?

As you known, it is possible catch any signal but kill and stop/count with an handler. There’s three kind of invalid address access : The attempt to execute/jump at an invalid address. The attempt to read at an invalid address. The attempt to write…
user2284570
  • 2,891
  • 3
  • 26
  • 74
0
votes
1 answer

How to have signal handler print time elapsed?

I am writing a C program that has a sigaction handler. It also has a itimerval in case SIGALRM doesn't come in a while. The handler should print the total number of infinite loop completed print the time elapsed exit(1); I noticed that signal…
Sara Takaya
  • 298
  • 2
  • 17
0
votes
0 answers

Why shouldn't I include , and how do I ignore the error when I do so?

I'm currently trying to instrument part of the SPEC OMP 2012 benchmark suite using the Score-P profiling tool, and I'm getting an error. Specifically: /XXX/imagick/src/magick_magick.c: In function…
tonysdg
  • 1,335
  • 11
  • 32
0
votes
1 answer

Do I need to check for my threads exiting?

I have an embedded application, running as a single process on Linux. I use sigaction() to catch problems, such as segmentation fault, etc. The process has a few threads, all of which, like the app, should run forever. My question is whether (and…
Mawg says reinstate Monica
  • 38,334
  • 103
  • 306
  • 551
0
votes
0 answers

can't get GETCHLD signal for second time c linux eclipse

i have program which sends signal SIGCHLD to all other processes in the system TWICE. problem is, its sent only once. program sending the signal: int main(){ kill(-1, SIGCHLD); sleep(8); kill(-1, SIGCHLD); return 0;} program getting the…
Zohar Argov
  • 143
  • 1
  • 1
  • 11
0
votes
1 answer

Using signals in C, how to stop and continue a program when timer ends

I'm developing a program that runs on a Raspberry-Pi (linux), that gets data from GPS modules and processes it. Right now, the program is centered around a while(1) loop that takes the GPS data and does stuff with it, (data is streamed at the…
0
votes
1 answer

Signals in the "set" parameter of sigtimedwait() not getting delivered

I have been working on signal handling on Linux lately, and have read all the concepts related to signal handling. One question that's tinkering my head is that why the signal in the set of sigtimedwait() doesn't get delivered while the process is…
0
votes
1 answer

Using sigaction with or without sigsetjmp

I have an exercise for which I have to implement a function that takes as parameters a one-parameter function pointer fun, a parameter to the function pointed at by said pointer parameter and an integer period. This function will return either 1 in…
WIlopu
  • 47
  • 7
0
votes
3 answers

C - Calling a function declared with parameters with no parameters?

I'm trying to understand a code which have the following lines: void terminate_pipe(int); code code code... struct sigaction new_Sigiterm; new_Sigiterm.sa_handler = terminate_pipe; My question are: What is the meaning of calling a function like…
Gum Bi
  • 313
  • 2
  • 4
  • 11
0
votes
1 answer

reacting to two signals sent to the CPU in linux

I wrote the following code: void handler (int signal) { if (signal==SIGVTALRM) { printf("one second passed\n"); } if (signal==SIGALRM) { alarm(1); //printf("curret context is %ld\n" , thread_tbl[currThreadNum].uc.uc_mcontext.cr2); …
CrazySynthax
  • 13,662
  • 34
  • 99
  • 183
0
votes
1 answer

Proper way of handling SIGCHLD, EINT, and accept() in Linux

I have a program that creates a TCP server. When the accept() connects to a client, I fork() it and handle the connection. When that client leaves it calls the waitpid() because of the SIGCHLD, but this causes a EINTR in the accept(). My question…
Rich G.
  • 61
  • 1
  • 1
  • 5
0
votes
1 answer

Segmentation fault when using linux create_timer and sigaction API

I'm trying to integrate the following piece of code into a bigger program (Which unfortunately, I cannot share) that runs on an ARM<->DSP system: #include #include #include #include #include…
ytm
  • 461
  • 1
  • 5
  • 16
0
votes
0 answers

The right way to wait for input after sigaction handling ctrl+c aka SIGINT

This program will print infinite "Enter a:" to the command line, after sending SIGINT via Ctrl + C. To exit this loop, I use Ctrl + \. If I uncomment the line containing std::cin.clear();, everything works fine. My question is, is this the right way…
kiigass
  • 427
  • 1
  • 4
  • 16
-1
votes
1 answer

Sending SIGINT signal to child process that uses execvp in C

I'm making a shell in C and I need to be able to handle SIGINT and SIGTSTP signals so as the shell doesn't terminate but it passes the signals to the child processes. I've found various posts here saying I should either use kill(child_pid,SIGINT) in…
stefnto
  • 85
  • 3
  • 8
-1
votes
1 answer

Trapping all signals in C to avoid memory leak

I made myself a webserver in C that connects to older hardware when users request a page. Here's pseudo code of what I did. Allocate only one large memory chunk for all variables via Malloc. run an endless loop to wait for new connections. The…
Mike
  • 9
  • 2