signals

Ignore SIGINT signal in child process

纵饮孤独 提交于 2019-12-05 15:02:42
问题 I am writing a simple program in which parent and child process are alternatively printing into a file. I have managed to do this using user defined signals. Now I want to handle the SIGINT signal. Once ctrl-c is received the parent must send termination signal to child,the child should then should terminate and finally the parent should terminate. My question is, in order to make this work properly I must catch the SIGINT signal ONLY from parent and IGNORE it from child. Is it right? If yes

Saving work after a SIGINT

两盒软妹~` 提交于 2019-12-05 14:42:52
I have a program which takes a long time to complete. I would like it to be able to catch SIGINT (ctrl-c) and call the self.save_work() method. As it stands, my signal_hander() does not work since self is not defined by the time the program reaches signal_handler() . How can I set it up so self.save_work gets called after a SIGINT ? #!/usr/bin/env python import signal def signal_handler(signal, frame): self.save_work() # Does not work exit(1) signal.signal(signal.SIGINT, signal_handler) class Main(object): def do_stuff(self): ... def save_work(self): ... def __init__(self): self.do_stuff()

Segmentation Fault Catch

泄露秘密 提交于 2019-12-05 13:53:27
I have a python script and it will loop through bunch of maya files and do some stuff. But some time maya get seg fault and my script will stop there. I tried with signal and multiprocess. But both failed import os, optparse, glob, json, signal import maya.standalone import maya.cmds as cmds from multiprocessing import Process, Queue def loadMayaBd(): maya.standalone.initialize(name='python') def sig_handler(signum, frame): print "segfault" def doSome(args, options): signal.signal(signal.SIGSEGV, sig_handler) loadMayaBd() #from here its just a example fileNameList = args[0] for eachFile in

Need something like a finished-signal from QWidget

房东的猫 提交于 2019-12-05 12:58:45
问题 I'm searching for something like the finished-signal from QDialog , only for QWidget . The reason is, I disable my toolbar once the widget pops up (which isn't a problem at all) and I want the toolbar to be enabled again, once the widget is closed. I also can't override the close-Event of that widget, because then we would have GUI-code in business-classes. 回答1: You can set the widget to be deleted on close, and then listen to its destroyed signal: widget->setAttribute( Qt::WA_DeleteOnClose )

What is the difference between POSIX reliable signals and POSIX real-time signals in Linux?

孤街醉人 提交于 2019-12-05 11:51:22
I read the man page of a signal using man 7 signal where I see two types of signal. So, I have question, What is the difference between POSIX reliable signals and POSIX real-time signals in Linux? These days, it might be better to phrase these as ordinary signal semantics versus realtime signal semantics. In some early UNIX systems, signals were unreliable in that they could be "lost", because there was no facility to block signals (to keep them pending). For example, code about to call pause() after checking a wake_up_flag set by a signal handler might miss the wake up instruction if the

Send ctrl-break to java process on 64-bit Windows ala sendsignal on 32-bit

时光怂恿深爱的人放手 提交于 2019-12-05 11:42:24
I frequently use the sendsignal tool for WebSphere Application Server processes (server, launchClient, wsadmin, etc.) in order to generate heap dumps. However, sendsignal doesn't work on 64-bit machines. Does anyone know of an alternative for sending the ctrl-break to a remote process? Update: Bengt points out that this is basically the same as the following question. So, I guess my question is: has anyone found a way around this limitation in the past two years? Can I send a ctrl-C (SIGINT) to an application on Windows? Why use a control break for the dumps why not use the commands that are

Enter-Notify-Event Signal not working on gtk.ToolButton

北战南征 提交于 2019-12-05 11:12:14
On a happy (if not irrevelent) note, this is the absolute last obstacle in this particular project. If I fix this, I have my first significant dot release (1.0), and the project will be going public. Thanks to everyone here on SO for helping me through this project, and my other two (the answers help across the board, as they should). Now, to the actual question... I have a toolbar in my application (Python 2.7, PyGTK) which has a number of gtk.ToolButton objects on it. These function just fine. I have working "clicked" events tied to them. However, I need to also connect them to "enter-notify

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

旧街凉风 提交于 2019-12-05 10:34:12
问题 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

Determine if a function is async-signal-safe (can be called inside a signal handler)

可紊 提交于 2019-12-05 10:32:04
My questions are: Is there a way to conclusively determine if a function is async-signal-safe if you don't have access to its implementation? If not, is there a way to test if function would be async-signal-safe enough to call from a signal handler? If you reads the man pages of signal() or sigaction(), you get a list of async-signal-safe functions (functions that can be safely called inside a signal handler). However, I believe that this list is not exhaustive. For example, the following page http://linux.die.net/man/7/signal , under the Async-signal-safe functions header, reads: POSIX.1-2004

cygwin ssh gives “Killed by signal 1” on exit

一笑奈何 提交于 2019-12-05 10:07:24
问题 After using cygwin's ssh to login from windows to linux-hosts, when exiting the remote shell, I always get the annoying msg: "Killed by signal 1" I googled, and realize its harmless, but still annoying... Some suggested you can get rid of the message by using $ ssh -q ... But that has no effect on any of the machines I've tried. Anyone knows a working solution to get rid of this msg? 回答1: Adding following line to your ~/.ssh/config file can squash that message. Update: QUIET must be all CAPS