How can I tell in Linux which process sent my process a signal

Two Linux-specific methods are SA_SIGINFO and signalfd(), which allows programs to receive very detailed information about signals sent, including the sender’s PID. Call sigaction() and pass to it a struct sigaction which has the desired signal handler in sa_sigaction and the SA_SIGINFO flag in sa_flags set. With this flag, your signal handler will receive three … Read more

How to handle a signal.SIGINT on a Windows OS machine?

[*] Python’s os.kill wraps two unrelated APIs on Windows. It calls GenerateConsoleCtrlEvent when the sig parameter is CTRL_C_EVENT or CTRL_BREAK_EVENT. In this case the pid parameter is a process group ID. If the latter call fails, and for all other sig values, it calls OpenProcess and then TerminateProcess. In this case the pid parameter is … Read more

What does WEXITSTATUS(status) return?

WEXITSTATUS(stat_val) is a macro (so in fact it does not “return” something, but “evaluates” to something). For how it works you might like to look it up in the headers (which should be #included via <sys/wait.h>) that come with the C-compiler you use. The implementation of this macro might differ from one C-implementation to the … Read more

Golang catch signals

There are three ways of executing a program in Go: syscall package with syscall.Exec, syscall.ForkExec, syscall.StartProcess os package with os.StartProcess os/exec package with exec.Command syscall.StartProcess is low level. It returns a uintptr as a handle. os.StartProcess gives you a nice os.Process struct that you can call Signal on. os/exec gives you io.ReaderWriter to use on … Read more

PyQt proper use of emit() and pyqtSignal()

You can define your own slot (any python callable) and connect that to the signal, then call the other slots from that one slot. class Example(QWidget): def __init__(self): super().__init__() self.initUI() def printLabel(self, str): print(str) def logLabel(self, str): ”’log to a file”’ pass @QtCore.pyqtSlot(int) def on_sld_valueChanged(self, value): self.lcd.display(value) self.printLabel(value) self.logLabel(value) def initUI(self): self.lcd = QLCDNumber(self) self.sld … Read more

Alternative to sun.misc.Signal

As you will find repeated ad infinitum when learning about signal handling in Java, you are encouraged to avoid writing Java code that depends directly on signals. The general best practice is to allow the JVM to exit normally on ctrl+c and other signals by registering a shutdown hook instead. Handling signals directly makes your … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)