Skip to content

Tag: signals

WIFSTOPPED is not working properly

I am trying to implement the fg command in my mini shell. The problem is as follows: A process(gedit) is started in foreground. I stop with ctrl+z and check exit my wait loop by checking the return value of WIFSTOPPED(status): I want this to resume when fg command is given: But WIFSTOPPED keeps returning non …

Signal and output in c

Some time ago I found this exercise in C: without changing the main function, so that receiving a SIGUSR1 signal output is directed and added to a file in append mode as the first parameter. At the reception of another SIGUSR1 the output is directed to the console, and so on. How do such an exercise? Answer I…

SIGALRM, interval timers and problems with sleep()

I am working with porting one of our embedded microcontroller libraries to linux and writing a python wrapper around it. One of my low level modules depends on a callback that gets called every 10ms. This callback counts up software timers that each have callbacks of their own. These timers are used all over …

Which thread handles the signal?

I have 2 threads(thread1 and thread2). And I have signal disposition for SIGINT. Whenever SIGINT occurs thread 2 should handle the signal. For that I wrote below program I compiled and and run the program. for every 1 second “thread1 active” is printing and for every 3 seconds “thread2 activ…

Sending signal to pthread to abort sleeping

I’m have a pthread function, which sleeps most of the time using usleep() I would like to send a signal from the main process to the thread to interrupt the sleeping sometimes. The problem is that I can’t find any reference of which signal exactly to send using pthread_kill() the usleep() man page…

Delete a Linux signal handler in C

I use: To add handler of SIGINT event. But how can i delete this handler? Answer Here is what you do: That resets the signal handler back to whatever the default behavior was for that signal (including the default disposition if it hasn’t been set). In the case of SIGINT, it’s aborting your proces…