Questions tagged [sigprocmask]

22 questions
31
votes
1 answer

Set and Oldset in sigprocmask()

I haven't completely understood, how to use sigprocmask(). Particularly, how the set and oldset and its syntax work and how to use them. int sigprocmask(int how, const sigset_t *set, sigset_t *oldset); Please explain with an example, to block, say…
Sushant
  • 1,013
  • 1
  • 11
  • 20
7
votes
2 answers

sigprocmask( ) blocking signals in UNIX

i have written a small piece of code. This code first blocks the {SIGSEGV}, then adds SIGRTMIN to the same set. So, my final signal set is, {SIGSEGV,SIGRTMIN}. Thus, if i use SIG_UNBLOCK, as per my understanding, first SIGRTMIN should be unblocked,…
RajSanpui
  • 11,556
  • 32
  • 79
  • 146
4
votes
1 answer

OS X sigaction incorrectly setting sa_mask

On a macbook (OSX 10.9.5 (13F34)) the following simple program: #include #include static void nop(int unused) { } int main(void) { struct sigaction sa, osa; sigset_t mask; sigemptyset(&sa.sa_mask); …
Dave
  • 10,964
  • 3
  • 32
  • 54
3
votes
2 answers

sigprocmask during signal's execution

I'm currently researching using sigprocmask to block certain signals (in this case, SIGALRM and SIGCHLD) when a critical segment of code is executing. Both of the signal handlers associated with these signals will access and modify a central data…
BSchlinker
  • 3,401
  • 11
  • 51
  • 82
3
votes
1 answer

sigprocmask() causing segfault

Are there any well known reasons for sigprocmask() to segfault when used in a multithreaded application? I have an application that creates multiple threads using clone(). I have determined that for some reason when I use sigprocmask it segfaults…
TripShock
  • 4,081
  • 5
  • 30
  • 39
2
votes
1 answer

Should child processes also be unblocking blocked SIGCHLD signals?

I'm trying to understand how blocking and unblocking signals work and I'm trying to understand the following piece of code. Specifically I am looking at line 28 (commented in the code): int a = sigprocmask(SIG_UNBLOCK, &mask, NULL);, aka where the…
Evan
  • 193
  • 9
2
votes
0 answers

sigprocmask with SIG_BLOCK doesn't block SIGALRM

Its a sample program to check if sigprocmask actually blocks the SIGALRM signal associated with my timer. Turns out it doesn't. My handler gets called even when the signal is BLOCKED. Would really appreciate if someone can point out why that is.…
emhr23
  • 31
  • 4
2
votes
1 answer

Official doc of ALL cleanup steps after fork before exec

On Unix, I'm aware that after calling fork(), I need to reset my signal mask and close file descriptors that I don't want the child to have, before calling exec(). But, what else might I need to do? Is there a comprehensive doc somewhere that lists…
dataless
  • 388
  • 4
  • 9
1
vote
1 answer

What is the idea behind the way the signals are used here?

While reading up and learning about signals, I found a program, that uses signals in a specific way. I tried understand it, but I am not sure, how all the parts of the code interact with another. Below is the above mentioned code and I added…
Imago
  • 521
  • 6
  • 29
1
vote
1 answer

sigset_t unix using sigprocmask()

I am trying to print sigset using printf. In this program, I have used sigprocmask to block SIGHUP and SIGTERM. After initializing set and oset to empty sets, they are giving some random hex strings as output. How should I solve this problem?? Also,…
user3660655
  • 45
  • 1
  • 7
1
vote
1 answer

sigprocmask doesn't restore my signal handler

I have a problem with my code C Unix. I'll copy crucial parts: So after the first sigprocmask I send a signal, after the SIG_UNBLOCK, doesn't work the previous handle(gestisciSignalDopoReg) instead the standard handle manage my signal, so it simply…
anto150192
  • 539
  • 3
  • 13
1
vote
1 answer

How to block signals in C?

I'm trying to create a program that blocks the signal SIGUSR1 and the it unblocks the signal. In the middle I want to see that the signal is blocked using sigpending. But it always says that the signal isn't blocked, and I can use the signal when…
Jack
  • 321
  • 1
  • 2
  • 11
0
votes
1 answer

Implementing sigprocmask(signals) in xv6

I am trying to implement sigprocmask in XV6. In that if the first parameter i.e how=SIG_UNBLOCK then as per my understanding the process mask must be removed. For that I was instructed to do curproc->sigmask &= ~(*set); But I am unable to…
0
votes
1 answer

sigprocmask resulting in main process getting stuck

I have multi threaded code which used sigprocmask fn. Its known that use of this call is unspecified in Multi threaded program which I understand and i will remove this call. However, the issue that I am facing is that my main thread is stuck if…
0
votes
1 answer

Xcode profiler: sigprocmask & __sigaltstack overhead

I am profiling my app (built with Codename One) using Xcode and an iPhone X device. I notice that, during heavy calculations (single- or multithreaded), sigprocmask and __sigaltstack (from libsystem_kernel.dylib) are the biggest time consumers with…
J-J
  • 419
  • 2
  • 12
1
2