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
1 answer

How to set more than one flag in sigaction.sa_flags

I have the following structure: struct sigaction sa1; sa1.sa_flags=SA_SIGINFO; sa1.sa_flags=SA_NODEFER; sa1.sa_sigaction = handler; sigaction(SIGUSR1,&sa1,NULL); How can I use SA_SIGINFO along with SA_NODEFER without making the second flag…
A. Harkous
  • 252
  • 1
  • 3
  • 14
1
vote
0 answers

sigaction, implicit declaration

I am trying to catch signals in c and ignore them for the parent process while the child handles them normally. I currently have: #include #include int main(){ struct sigaction parentsig, childsig; …
Nick
  • 11
  • 4
1
vote
1 answer

Sigaction vs Signal

Can someone please explain the difference between sigaction and signal. I know they signal works differently depending on which machine you are working on i.e. Mac, Windows, or Linux and that sigaction works the same on all platforms. But my…
divyanshch
  • 390
  • 5
  • 15
1
vote
1 answer

When (and why) use "sigaction()" instead of "signal()"?

I am looking deeply on the system function signal() and sigaction() I read some pages on these two functions, and they mainly talked about the differences as portability and the "no - race condition". Could anyone clarify these for me? p.s. I was…
Iankimm
  • 11
  • 1
0
votes
1 answer

question about handling signals using signal in C

The program is a server that receives messages from the client by transmitting SIGUSR1 or SIGUSR2 signals and decrypts them using bitwise operations (but this is not important yet). The server shows the PID and then waits for a SIGUSR1 or SIGUSR2…
0
votes
2 answers

Setting user defined signal actions and defaults (macOS and Linux)

I need a function that allows to either specify a user defined signal action, to reset it to default, or to ignore the signal. The code so far is int setsig(int signum, void (*action)(int, siginfo_t *, void *)) { struct sigaction sig; …
olebole
  • 521
  • 4
  • 17
0
votes
0 answers

My scheduler stops when a executing process stops but does not terminate

So, I have a scheduler in c that sends another c program to execute every second. Then gets switch out for another program for a second in round robin style using a queue. However, I can change the amount of time the scheduler executes each process.…
Praytiki
  • 1
  • 1
0
votes
0 answers

Blocking SIGQUIT when SIGUSR1 handler is running

I have the following program which I have almost solved: There are two processes: a parent process (P0) creates five children; after that, the parent process sends five times a SIGUSR1 signal to each of its children and goes sleeping for 1 second.…
aghin00
  • 3
  • 1
0
votes
0 answers

UART triggered wrong with termios and sigaction

Hello stack overflow community. It's not easy to explain the problem. Hope you can understand. Setup is a Linux embedded board where I want to communicate over UART. The Board has an imx6ULL. The Linux was builded with Yocto 3.1.5 (dunfell). To…
0
votes
1 answer

struct sigaction is not defined (Visual Studio)

I try to catch a signal, but struct sigaction is not defined in . Previously, this worked on Ubuntu with gcc compiler. Some piece of code: #include #include #include #define _POSIX_C_SOURCE …
kancler
  • 81
  • 1
  • 8
0
votes
1 answer

checking for errors in a program that implements a System V signal API using the standard POSIX API

How can I modify the error checking program? I check or pass the returned value of sigprocmask (), but I don't check the return value of most other sig * () functions. However, it all returns an error code that I should check. How can I do that? I…
Lorand
  • 29
  • 4
0
votes
1 answer

Get sigaction structure

Trying to build paho_c_pub.c with help of Visual Studio 2019 on my Raspberry Pi machine connected via ssh. Code uses structure sigaction from that is not visible by compiler: Error invalid application of ‘sizeof’ to incomplete type…
vico
  • 17,051
  • 45
  • 159
  • 315
0
votes
1 answer

client - server program for transmitting text using signals SIGUSR1, SIGUSR2

server typedef struct s_server { unsigned char c; int counter; } t_server; t_server server; void ft_one(int sig, siginfo_t *info, void *context) { (void)sig; (void)context; server.c += server.counter; …
Cleonia
  • 33
  • 3
0
votes
2 answers

Getline stops working after sigchld is received

I have been experimenting with signals and I am facing a problem I can not explain. I have recreated my issue in this simple C program, in a nutshell I am reading user input in a loop using getline(). The user can fork the process, kill the child…
Martian
  • 94
  • 1
  • 9
0
votes
1 answer

Is sa_mask default value empty?

I'm trying to implement a signal handler and was wondering if I need to explicitly empty sa_mask field of the struct sigaction or if by initializing it with default value is sufficient.