signals

Can we reset sigsetjmp to return “0” again (Reset sigsetjmp)?

我是研究僧i 提交于 2019-12-03 22:22:39
I have written a segmentation fault handler, using sigsetjmp and siglongjmp. Once it goes to the signal handler, i invoke siglongjmp so that the faulty instruction is skipped. Problem is, i again want to cause SIGSEGV and go to the same handler, but now sigsetjmp will return 1. How to reset sigsetjmp? Here is my code: #include <stdio.h> #include <memory.h> #include <stdlib.h> #include <unistd.h> #include <sys/mman.h> #include <sys/types.h> #include <fcntl.h> #include <signal.h> #include <setjmp.h> sigjmp_buf env, env1; void SIGSEGV_handler(int signal) { printf("Segmentation fault caught\n");

SEH Equivalent in Linux or How do I handle OS Signals (like SIGSERV) and yet keep continuing

与世无争的帅哥 提交于 2019-12-03 20:50:14
问题 I am currently working on a Unit Testing framework where users can create Test Cases and register with the framework. I would also like to ensure that if any of the User Test Code causes a Crash, it should not Crash the entire framework but should be flagged as failed. To Make this work, I wrote up the following Code so that I can run the Users Code within the Sandbox function bool SandBox(void *(*fn)(void *),void *arg, void *rc) { #ifdef WIN32 __try { if (rc) rc = fn(arg); else fn(arg);

How, in Perl 5, can I get the pid of the process who sent me a signal?

余生长醉 提交于 2019-12-03 19:17:07
问题 In C, I can say #include <stdio.h> #include <unistd.h> #include <signal.h> int continue_running = 1; void handler(int signal, siginfo_t* info, void* data) { printf("got signal %d from process %d running as user %d\n", signal, info->si_pid, info->si_uid); continue_running = 0; } int main(int argc, char** argv) { struct sigaction sa; sigset_t mask; sigemptyset(&mask); sa.sa_sigaction = &handler; sa.sa_mask = mask; sa.sa_flags = SA_SIGINFO; sigaction(SIGTERM, &sa, NULL); printf("pid is %d\n",

django temporarily disable signals

倖福魔咒の 提交于 2019-12-03 17:35:35
问题 I have a signal callback in django: @receiver(post_save, sender=MediumCategory) def update_category_descendants(sender, **kwargs): def children_for(category): return MediumCategory.objects.filter(parent=category) def do_update_descendants(category): children = children_for(category) descendants = list() + list(children) for descendants_part in [do_update_descendants(child) for child in children]: descendants += descendants_part category.descendants.clear() for descendant in descendants: if

ORA-24550: signal received: [si_signo=6] error

本小妞迷上赌 提交于 2019-12-03 16:15:19
I want to know what ORA-24550: signal received: [si_signo=6] means? I know this is an oracle error and may an oracle latest patch can solve the issue. When this error is triggered, like the scenario where this signal has to be handled or whether this error occur when my application has to handle something related to oracle and the application failed to do that. Wilfred Hughes This is a sign that your Oracle client has received a signal it wasn't expecting. The Oracle docs say: ORA-24550: unhandled signal #number received. string Cause: Serious error: signal received Action: Refer to the

Get pid of the process which has triggered some signal

 ̄綄美尐妖づ 提交于 2019-12-03 16:12:25
Is it possible to find out the process id of the process which has caused some signal. In my scenario, I have multiple children of a process running, and I want to know which one of them sent the signal. It is (finally!) very simple with python 3. The following is tested with python 3.3.3: #! /usr/bin/python3 import signal import time, os def callme(num, frame): pass # register the callback: signal.signal(signal.SIGUSR1, callme) print("py: Hi, I'm %d, talk to me with 'kill -SIGUSR1 %d'" % (os.getpid(),os.getpid())) # wait for signal info: while True: siginfo = signal.sigwaitinfo({signal

Why does ignoring SIGTRAP not work with asm?

会有一股神秘感。 提交于 2019-12-03 16:04:42
I'm trying to ignore SIGTRAP. I have the following proof-of-concept code: #include <signal.h> #include <stdlib.h> int main(){ signal(SIGTRAP, SIG_IGN); write(1, "A", 1); asm("int3"); write(1, "B", 1); return 0; } When I run it, I expect to see "AB", but I see ATrace/breakpoint trap (core dumped) Why does my program terminate despite it ignoring SIGTRAP? According to this site a blocked/ignored signal is automatically unblocked inside the kernel code when it is raised. So if the same signal is raised repeatedly, an infinite loop will not happen. Instead the application is terminated on the

In detail, what happens when you press Ctrl-C in a terminal?

时间秒杀一切 提交于 2019-12-03 15:52:25
In detail, what happens when you press Ctrl-C in a terminal? Yes, I know that it sends SIGINT, but what steps does it take to get there? I have done some research so I think I understand most of the picture, but not all of it. For the sake of pedagogy, I will assume we are running a terminal emulator, xterm, in an X session. The terminal is running the Bash shell, and the shell is currently running some long running pipeline consisting of multiple processes in the foreground. I press Ctrl-C in the keyboard. X sends the keyboard event to xterm. xterm translates the Ctrl-C keyboard event and

how to send signal from one program to another?

青春壹個敷衍的年華 提交于 2019-12-03 15:49:50
i am using message queue as an ipc between 2 programs. Now i want to send data from one program to another using message queue and then intimate it through a signal SIGINT. I dont know how to send a signal from one program to another . Can anybody pls provide a sample code if they have the solution. #include <sys/types.h> #include <signal.h> int kill(pid_t pid, int sig); Signal in linux can be send using kill system call just check this link for documentation of kill system call and example. you can see man -2 kill also. and it's not advisable to use SIGINT use SIGUSR1 or SIGUSR2 Note that by

How to disable ctrl-z, ctrl-c from breaking out of a php script

不想你离开。 提交于 2019-12-03 15:28:28
问题 Can someone point me in the correct direction for researching how to prevent users from breaking out of a php script with Ctrl + Z , Ctrl + C ? 回答1: If you have php compiled with PCNTL (Process Control) and are not running Windows you can use pcntl_signal(). There is an example here which I modified, and it seems to catch Ctrl-C ok: <?php declare(ticks = 1); pcntl_signal(SIGINT, "signal_handler"); function signal_handler($signal) { switch($signal) { case SIGINT: print "Ctrl C\n"; } } while(1)