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

linux C languang. setjmp longjmp alarm

execute my code jmp_buf a; void sig_handler(int signum) { if(signum == SIGINT) exit(0); printf("In the handler\n"); sleep(2); alarm(3); longjmp(a,1); } int main(int argc, char *argv[]) { int j=0; …
hkjaaaip
  • 63
  • 1
  • 1
  • 5
2
votes
2 answers

sigaction: incorrect member name

I'm in the process of transitioning my program's signal handling from signal() to sigaction(). According to the UNIX spec a struct sigaction should have at least 4 members; sa_handler, sa_mask, sa_flags and sa_sigaction. When I define a structure as…
Nick
  • 56
  • 6
2
votes
0 answers

Using sigaction and setitimer system calls to implement assembly language timer on BSD/OS X

I'm trying to implement a timer routine in 32-bit assembler on OS X Lion using sigaction() & setitimer() system calls. The idea is to set a timer using setitimer() & then have the generated alarm signal invoke a handler function previously setup…
frijid
  • 21
  • 3
1
vote
2 answers

Why isn't my SIGUSR1 signal being processed?

I have a strange problem. I want to write a simple C programm that outputs "Daytime" repeatedly unless I press Ctrl+C (a SIGINT signal) which makes it to switch to "Nighttime" and vice versa. This part of the programm works. I also want to implement…
user18917702
1
vote
2 answers

waitpid() fail sometime when SIGINT is sent by a ctrl+c

waitpid() returns -1 from time to time when the process in question has received a SIGINT via a ^C. But I can't reproduce this problem if I send a SIGINT signal via pkill for example. The value of errno is set to EINTR. I have a parent process that…
lseiller
  • 25
  • 4
1
vote
1 answer

The process is receiving the masked signals after sigsuspend

sigsuspend is a function that changes the mask and suspends the process until a new signal is delivered, but what surprised me is that the pending signals are being delivered also after the sigsuspend. For example: while the process is sleeping (5…
SBAT
  • 49
  • 5
1
vote
2 answers

SIGINFO's si_pid sets itself to 0 after a few calls of the same function

I'm working on a simple project that makes 2 processes communicate to each other using signals. More specifically, I'm using sigaction with the flag SA_SIGINFO so that each process can identify who sent it a signal and reply. Thing is, after they…
xle-boul
  • 19
  • 3
1
vote
0 answers

Ignore linux process signals such as SIGTERM using sigaction from .NET app

I am not really familiar with .NET interop. Am trying to implement the ignoring of linux process signals in .NET, using a call to sigaction. The interop definitions I could come up with are as follows: public delegate void __sighandler_t(int…
Veverke
  • 9,208
  • 4
  • 51
  • 95
1
vote
1 answer

Both registering signal handler for SIGSEGV and still being able to create full crash dump from OS

We are using the standard pattern of registering custom signal handler for SIGSEGV with sigaction and then when segmentation fault occurs using the backtrace function to walk the stack and print it to some file. It is nice feature to have the…
Boris
  • 1,311
  • 13
  • 39
1
vote
0 answers

Why is my signal handler for SIGFPE called only once?

#include #include #include #include #include #include static jmp_buf begin; void sigAction(int signum, siginfo_t* siginfo, void* context) { sigset_t oset; sigemptyset(&oset); …
Bugsy
  • 103
  • 7
1
vote
2 answers

Porting a C code to Windows from POSIX (problem with siginfo)

I am trying to compile the program 'MRCC' (developed for Linux) natively under Windows. The program is mainly written in Fortran, while the interface with the system is written in C as far as I can tell. All of the source files compile successfully…
S R Maiti
  • 237
  • 3
  • 13
1
vote
0 answers

what is the correct values to assign to sa_mask field of sigaction struct

#include #include #include #include void sigint_handler(int sig) { write(0, "nice try\n", 10); } int main(void) { struct sigaction sa; // configure sigaction sa.sa_handler=sigint_handler; …
asha rani
  • 11
  • 1
1
vote
1 answer

Get the register causing a segmentation fault in a signal handler

I know that: When installing a SIGSEGV signal handler with sigaction and a sa_sigaction (rather than sa_handler), the signal handler receives a siginfo_t*, of which the si_addr is the address at which the fault occurred. Using the ucontext_t we…
user13853391
1
vote
1 answer

si_value not a member of siginfo_t inside sigaction handler using POSIX message queues

I am sure I am missing something obvious but my problem is as follows. As a programming exercise I am trying to create an async posix message queue server to handle incoming messages asynchronously in a handler. Now according to my documentation…
Alex Hoffmann
  • 355
  • 4
  • 20
1
vote
0 answers

Sigaction and setitimer in C

1I am trying kill a child process after 1 second. The child process is an external c program that runs some nested for loops and and prints "ALL DONE" if it makes it through. The loops take about 10 seconds, so if I set up my timer and action…