Skip to content
Advertisement

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 zero so waitpid is breaking

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’ll give you

linux: sigwait() takes precedence over pthread_sigmask(SIG_UNBLOCK)?

In a program, SIGCHLD is blocked from main thread, then thread “THREAD_1” is doing sigwait(), thread “THREAD_2” which forks a child process and kills it, in this thread I called pthread_sigmask(SIG_UNBLOCK, &set, 0) to unblock SIGCHLD before killing the child. But SIGCHLD is still being picked up by sigwait(). Other than unblock SIGCHLD from main() before creating threads, is there

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 our library and while they don’t

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 active” is printing. Now I generated SIGINT. But its printing “thread1

SIGPROF kills my server when using google perftools

I have a multithreaded server process, written in C/C++ that I am trying to profile with Google perftools. However when I run the process with perftools, pretty soon my server stops with a “syscall interrupted” error, that I think is being caused by the incoming SIGPROF. (The actual system call that is being interrupted is deep inside my call to

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, states that SIGALRM should not be used

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 process without a core dump. The manual

Advertisement