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
1
vote
0 answers

How to handle sigaction() gracefully and give back to parent process

Is there a way to catch a signal with sigaction and get back to parent process after handle the error properly? To be more specific, by following code I can do some error handle, but others can not get same crash notification after my sigaction…
hismart
  • 405
  • 6
  • 15
1
vote
1 answer

Walking a TAILQ in a signal handler

I have an application that maintains a list of structures, linked together by a TAILQ. Each structure has a dirty bit, and pointer to some dedicated special pages in memory. I need to know if someone writes to any of these pages, so I mprotect…
HardcoreHenry
  • 5,909
  • 2
  • 19
  • 44
1
vote
2 answers

How to only kill the child process in the foreground?

I am trying to build a shell, and I've managed to code most of the functionality in, however I have a small problem. Say I type firefox &. Firefox will open up as a background process. The & activates a BG flag that makes the parent not wait for the…
ENBYSS
  • 819
  • 1
  • 10
  • 22
1
vote
1 answer

waitpid and signal handler, C

I tried to find an answer to my question at this post: Signal handler and waitpid coexisting but for me isn't very clear at the moment. I try to explain my problems: I'm trying to write a C program that concerns IPC between a parent process and its…
gaet
  • 11
  • 1
1
vote
1 answer

Signal SIGSEGV Caught using sigaction

I am developing a multithread application running on linux pc kernel version 4.4.14. I want to track some catastrophic errors causing segmentation fault. I set up a signal handler linked to SIGSEGV to try to get the pid number of the thread causing…
mrcbis
  • 91
  • 1
  • 7
1
vote
1 answer

Why only async-safe functions should be called from a signal handler?

I understand that, from a signal handler function sigaction() I should only call those functions that are "async-safe". But why is so?
Asif
  • 664
  • 1
  • 7
  • 14
1
vote
1 answer

Portability of sigaction and sigset_t between Solaris and Linux

I have some legacy code on Solaris platform and I would like to port that to Linux, but I am getting some compilation error on Linux. On Solaris, I have the following code snippet: #include ... void f() { struct sigaction a; …
Dr. Debasish Jana
  • 6,980
  • 4
  • 30
  • 69
1
vote
1 answer

Program structure to catch SIGINT and call destructor in C++

Related to How can I handle interrupt signal and call destructor in c++?, but my question revolves around structuring a program. I am writing a simulation program that writes data out to HDF5 file. But in case of program interruption, I'd like the…
bernie
  • 546
  • 3
  • 13
1
vote
1 answer

Signal handling for background processes

I'm trying to implement a simple Unix shell in C. However, I could not implement background process feature by using sigaction. My code structure is like the following: int main() { struct sigaction act; act.sa_handler = handler; sigaction(SIGCHLD,…
Enes Altuncu
  • 449
  • 2
  • 7
  • 14
1
vote
1 answer

Cannot change default action for SIGINT

In C, I want to catch the SIGINT signal and print out a message like "SIGINT received" by using sigaction and passing a new handler to it via sa.sa_sigaction = handler; I don't want to terminate the program. If I run my program through the shell…
Big Dude
  • 264
  • 1
  • 6
  • 25
1
vote
0 answers

Storage size not know with gnu99 only on Windows but not Linux

I am writing code in C using sigaction. Compiling using minGW on Windows. I noticed that c99 doesn't support sigaction so I used the flag -std=gnu99 when compiling. Why does it give me the error message "storage size of 'newact' isn't known " only…
Sara Takaya
  • 298
  • 2
  • 17
1
vote
3 answers

sigaction handle signal just once

Is there a way to catch a signal just once with sigaction structure and function? To be more specific, I would like to simply reset to default a specific signal (SIGINT). Is it possible to achieve this in a handler? Edit So, something like this…
Papipone
  • 1,083
  • 3
  • 20
  • 39
1
vote
1 answer

C - Replace "No such file or directory" message

I'm trying to make a shell that whenever it can't execute a command it says "Error executing binary: -nameOfBinary-". But the thing is that it always gives me the message "No such file or directory". Heres part of my code: void handle_SIGINT() { …
Asfourhundred
  • 3,003
  • 2
  • 13
  • 18
1
vote
1 answer

Catching SIGSEGV when triggered by corrupt stack

I've been working on some buggy code and wanted to install a SIGSEGV handler to get more information about the crash. However, I noticed that my handler is not invoked. I've been looking for a reason and it seems it has to do with a corrupt stack…
1
vote
0 answers

sigio handling only input signal and not output c++

I'm working on an embedded system which send informations through the serial port uart ttyS0. Now i would like to receive data from the same serial port. So I implemented a signal handler using sigaction. I would like to use the SIGIO signal but the…
A. Kriss
  • 69
  • 5