signal-handling

Perl Term::ReadLine::Gnu Signal Handling Difficulties

我只是一个虾纸丫 提交于 2019-12-07 06:34:45
问题 I'm using Term::ReadLine::Gnu and have run into a problem with signal handling. Given the script below and a TERM signal sent to the script, the handler for the TERM signal is not triggered until after the enter key is pressed. Using Term::ReadLine:Perl this does not occur. I've read that Term::ReadLine::Gnu has its own internal signal handlers, but frankly I'm at a loss as to how to work with them. I've reviewed http://search.cpan.org/~hayashi/Term-ReadLine-Gnu-1.20/Gnu.pm#Term::ReadLine:

How do i remove a signal handler

跟風遠走 提交于 2019-12-06 17:27:08
问题 I've made the follow signal handler struct sigaction pipeIn; pipeIn.sa_handler = updateServer; sigemptyset(&pipeIn.sa_mask); sa.sa_flags = SA_RESTART; if(sigaction(SIGUSR1, &pipeIn, NULL) == -1){ printf("We have a problem, sigaction is not working.\n"); perror("\n"); exit(1); } How do I remove or block this particular handler so that I can set up another signal handler that uses the same signal? Thanks. 回答1: Use SIG_DFL in place of the function pointer when calling sigaction(2). 来源: https:/

Signal handler accessing queue data structure (race condition?)

纵饮孤独 提交于 2019-12-06 00:22:01
问题 I'm currently writing a small shell in C++. Jobs and the PIDs associated with them are stored within a queue of job pointers (job *) . When a new job is run, information about it is added to the queue. Since multiple jobs can be handled simultaneously and new jobs can be entered at the shell's console at any time, I have a signal handler to wait on jobs which are terminated. When a job is terminated, I need to remove it's information from the active job queue and move it to my deque of

How to deal with errno and signal handler in Linux?

六月ゝ 毕业季﹏ 提交于 2019-12-05 22:54:32
When we write a signal handler that may change the errno, should we save errno at the beginning of the signal handler and restore the errno at the end of it? Just like below: void signal_handler(int signo){ int temp_errno = errno; *** //code here may change the errno errno = temp_errno; } The glibc documentation says : signal handlers that call functions that may set errno or modify the floating-point environment must save their original values, and restore them before returning. So go ahead and do that. To those reading this who can't rewrite their signal handlers, there may be a workaround.

compile errors using signal.h in Linux [duplicate]

给你一囗甜甜゛ 提交于 2019-12-04 23:15:49
This question already has an answer here: struct sigaction incomplete error 2 answers I'm writing a shell program that must handle signals. My relevant signal handling related code is as follows: #include <signal.h> ... #include <sys/types.h> ... void installSigactions( int, struct sigaction* ); void handler_function( int signal_id ); ... /*define signal table*/ struct sigaction signal_action; /*insert handler function*/ signal_action.sa_handler = handler_function; /*init the flags field*/ signal_action.sa_flags = 0; /*are no masked interrupts*/ sigemptyset( &signal_action.sa_mask ); /*install

Signal handler accessing queue data structure (race condition?)

青春壹個敷衍的年華 提交于 2019-12-04 06:48:04
I'm currently writing a small shell in C++. Jobs and the PIDs associated with them are stored within a queue of job pointers (job *) . When a new job is run, information about it is added to the queue. Since multiple jobs can be handled simultaneously and new jobs can be entered at the shell's console at any time, I have a signal handler to wait on jobs which are terminated. When a job is terminated, I need to remove it's information from the active job queue and move it to my deque of terminated jobs. However, it is possible that a user's new job is being added to the queue when another job

Can I write-protect every page in the address space of a Linux process?

烂漫一生 提交于 2019-12-03 20:17:55
问题 I'm wondering if there's a way to write-protect every page in a Linux process' address space (from inside of the process itself, by way of mprotect() ). By "every page", I really mean every page of the process's address space that might be written to by an ordinary program running in user mode -- so, the program text, the constants, the globals, and the heap -- but I would be happy with just constants, globals, and heap. I don't want to write-protect the stack -- that seems like a bad idea.

Trap all accesses to an address range (Linux)

蓝咒 提交于 2019-12-03 09:38:39
问题 Background I'm writing a framework to enable co-simulation of RTL running in a simulator and un-modified host software. The host software is written to control actual hardware and typically works in one of two ways: Read/Write calls through a driver Memory mapped access using mmap The former case is pretty straightforward - write a library that implements the same read / write calls as the driver and link against that when running a simulation. This all works wonderfully and I can run un

How are asynchronous signal handlers executed on Linux?

隐身守侯 提交于 2019-12-03 00:47:06
问题 I would like to know exactly how the execution of asynchronous signal handlers works on Linux. First, I am unclear as to which thread executes the signal handler. Second, I would like to know the steps that are followed to make the thread execute the signal handler. On the first matter, I have read two different, seemingly conflicting, explanations: The Linux Kernel, by Andries Brouwer, §5.2 "Receiving signals" states: When a signal arrives, the process is interrupted, the current registers

Trap all accesses to an address range (Linux)

心已入冬 提交于 2019-12-03 00:23:11
Background I'm writing a framework to enable co-simulation of RTL running in a simulator and un-modified host software. The host software is written to control actual hardware and typically works in one of two ways: Read/Write calls through a driver Memory mapped access using mmap The former case is pretty straightforward - write a library that implements the same read / write calls as the driver and link against that when running a simulation. This all works wonderfully and I can run un-modified production software as stimulus for my RTL simulations. The second case is turning out to be far