Questions tagged [signal-handling]

In the C Standard Library, signal processing defines how a program handles various signals while it executes. A signal can report some exceptional behavior within the program (such as division by zero), or a signal can report some asynchronous event outside the program (such as someone striking an interactive attention key on a keyboard).

290 questions
0
votes
0 answers

How my signal handler is called if a signal occurs during pselect?

I have a doubt on this question: how the signal handler sigterm is called during pselect syscall?
Harmonia
  • 5
  • 1
  • 3
0
votes
2 answers

Masking signal when global variables are being updated

I am aware that i can mask a signal from being raised when handler is executing (by using sa_mask). However, i would like to know how to mask a signal when i am updating some global variables. Also, i would like to know how to mask a signal when a…
CuriousCoder
  • 1,582
  • 5
  • 28
  • 55
0
votes
0 answers

Signal Handling on Windows and Linux

I have implemented signal handling in C on windows visual studio spefically for SIGBREAK and SIGSEVG but when i gave the added the code which could cause segmentation fault, my signal handler function dosent get call but if used raise(SIGSEVG),…
Steve
  • 1
  • 2
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
0 answers

Not getting Stacktrace of Backtrace while Function crashed with SIGABRT in ARM using libunwind library

I'm not getting Stacktrace of Backtrace while Function crashed with SIGABRT in ARM using libunwind library but Getting in case of SISEGV using same library. Hi, I'm not getting Stacktrace of Backtrace while Function crashed with SIGABRT in ARM using…
0
votes
1 answer

How to suspend a process just before it prints it's output in C?

I am trying to implement background jobs in C for my shell. The problem is it prints the output next to my prompt like this: user@hostmachine:/.../$: [output] I have now learnt that "stty tostop" helps suspend process just before it's output but…
amogh
  • 15
  • 6
0
votes
0 answers

sigsuspend() with SIGINT and SIGCHLD

I am studying this piece of code from the CSAPP book: #include "csapp.h" volatile sig_atomic_t pid; void sigchld_handler(int s) { int olderrno = errno; pid = Waitpid(-1, NULL, 0); errno = olderrno; } void sigint_handler(int…
0
votes
0 answers

Python signal handler weird behavior

As far as I know, the signal handler in Python is executed in main thread, so I try the following script: import signal, time from threading import Event def main(): running = True event = Event() def handler(signal,…
Lan Do
  • 63
  • 6
0
votes
2 answers

Accessing variables of main() function inside signal handler in C++

I want to change the variables declared in the main function using signal handler when an user defined signal is sent to the process. I do not want to use any global variables. Below is a sample code. #include #include void…
Abhilash
  • 3
  • 5
0
votes
1 answer

CTRL+C is not killing my program

I have a program which forks a child. I am trying to catch following signals: SIGINT, SIGPIPE and SIGTERM. On Ctrl+c (which generates SIGINT - afaik) I want to make sure I kill the child process before main program terminates which I am doing in…
hari
  • 9,439
  • 27
  • 76
  • 110
0
votes
1 answer

kill is unsafe respect to signals - any alternative?

I read that kill is unsafe respect to signals here. What else should I use if I want to kill child process as part of clean up inside my signal handler? What are my alternatives?
hari
  • 9,439
  • 27
  • 76
  • 110
0
votes
1 answer

Graceful signal handling in slurm

I have an issue with graceful exiting my slurm jobs with saving data, etc. I have a signal handler in my program which sets a flag, which is then queried in a main loop and a graceful exit with data saving follows. The general scheme is something…
PKua
  • 463
  • 3
  • 15
0
votes
0 answers

Library calls used to install signal-handling in C?

I know there are two system calls that can be used for this, but which one is preferred for portable code?
0
votes
1 answer

Why kill -15 does not gracefully kill my Golang gRPC service?

I have used signal handler to handle SIGTERM, SIGINT signals. When grpc server is up and running I issue sudo kill -15 [PID] command and I don’t see my graceful shutdown log reports and also I get: [1] 41983 terminated go run mypkg/main.go Now…
Alireza
  • 6,497
  • 13
  • 59
  • 132
0
votes
1 answer

Reinstalling set signals in C

I'm trying to handle multiple signals with one signal handler, the expected result is for ctrlc to exit the child process and also exit the parent process while ctrlz prints a random number everytime ctrlz is pressed but it doesn't seem to work…
Victor
  • 9
  • 2