signals

Paramiko and exec_command - killing remote process?

大憨熊 提交于 2019-11-28 07:38:44
I'm using Paramiko to tail -f a file on a remote server. Previously, we were running this via ssh -t , but that proved flaky, and the -t caused issues with our remote scheduling system. My question is how to kill tail when the script catches a SIGINT? My script (based on Long-running ssh commands in python paramiko module (and how to end them) ) #!/usr/bin/env python2 import paramiko import select client = paramiko.SSHClient() client.load_system_host_keys() client.connect('someserver', username='victorhooi', password='blahblah') transport = client.get_transport() channel = transport.open

Catch Windows terminal closing on running process

自作多情 提交于 2019-11-28 06:00:54
问题 In a command prompt window, I have a running process. While the process is still executing, I click the (red) 'X' in the corner of the command prompt window. The command prompt window closes, and the running process is terminated. On Linux, closing the parent terminal of a running process will send that process SIGHUP . How do I catch this event on Windows? 回答1: The equivalent of SIGHUP is provided through the callback you register with SetConsoleCtrlHandler. Your callback function will be

Getting the saved instruction pointer address from a signal handler

蓝咒 提交于 2019-11-28 05:32:55
My question is somewhat different from others that have asked about fault addresses. I'm trying to implement a horrible hack to determine, from a signal handler, whether the signal interrupted a syscall or ordinary user code by inspecting the code at the saved instruction pointer and comparing it against the possible syscall entry instructions for the host architecture it's running on. This is part of implementing correct POSIX thread cancellation that does not suffer from the race condition and resource leak described in my old question: How are POSIX cancellation points supposed to behave?

Signal Handling in C

不羁的心 提交于 2019-11-28 05:25:05
How can I implement signal Handling for Ctrl-C and Ctrl-D in C....So If Ctrl-C is pressed then the program will ignore and try to get the input from the user again...If Ctrl-D is pressed then the program will terminate... My program follows: int main(){ char msg[400]; while(1){ printf("Enter: "); fgets(msg,400,stdin); printf("%s\n",msg); } } Thanks, Dave When dealing with POSIX signals, you have two means at your disposal. First, the easy (but deprecated) way, signal() . Second, the more elegant, current but complex way, sigaction() . Please use sigaction() unless you find that it isn't

django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. file init

六月ゝ 毕业季﹏ 提交于 2019-11-28 05:08:50
问题 django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. Exception appeared when I added: import signals in init .py file (apps/application/init.py) from models import Review in signals.py file (apps/application/signals.py) I want to send an http request when there is an insert in the model Review. So I need to import Review model (in the __init.py__ file) to execute the following code: @receiver (pre_save, sender = Review) def my_handler (sender, ** kwargs): .... 回答1: In the

Is Django post_save signal asynchronous?

亡梦爱人 提交于 2019-11-28 04:22:01
I have a 'like' function which is just like social networks like or thumbs up function; the user clicks the star / heart / whatever to mark the content as liked. It is done with ajax and must be fast. The only problem here is that for some reasons I have to do some tasks for each 'like' and I found out they were coded straight in the 'like' view and it makes it slow. I am thinking of using signals to make the execution of these tasks asynchronous so the view can send back the json right away to the javascript without waiting for the tasks to finish. I started created a signal for the 'like'

Providing/passing argument to signal handler

落花浮王杯 提交于 2019-11-28 04:17:57
Can I provide/pass any arguments to signal handler? /* Signal handling */ struct sigaction act; act.sa_handler = signal_handler; /* some more settings */ Now, handler looks like this: void signal_handler(int signo) { /* some code */ } If I want to do something special i.e. delete temp files, can I provide those files as an argument to this handler? Edit 0: Thanks for the answers. We generally avoid/discourage use of global variables. And in this case, If you have a huge program, things can go wrong at different places and you might need to do a lot of cleanup. Why was the API designed this way

Which signal does ctrl-x send when used in a terminal?

≡放荡痞女 提交于 2019-11-28 04:06:38
On Linux/Unix there are signals. The Ctrl C one ( SIGINT ) is obvious to me. Now, in some other applications there are signals via Ctrl X ?! Is that even a signal or does it generate an escape sequence? Is there anything else I can use as something similar to Ctrl C ( Ctrl V , Ctrl X ...)? If anyone has a clue, im familiar with C more than bash, but answers in both languages are appreciated! jfg956 To get all the terminal control character assignments: stty -a Damon There is possibly a misunderstanding. Ctrl C does not generate a signal. It is perfectly possible to press Ctrl C anywhere, and

How to convert signal name (string) to signal code?

天大地大妈咪最大 提交于 2019-11-28 03:37:17
问题 I am writing a program that reads the name of the signal (e.g. SIGSTOP, SIGKILL etc) as a string from the command line and calls the kill() system call to send the signal. I was wondering if there is a simple way to convert the string to signal codes (in signal.h). Currently, I'm doing this by writing my own map that looks like this: signal_map["SIGSTOP"] = SIGSTOP; signal_map["SIGKILL"] = SIGKILL; .... But its tedious to write this for all signals. So, I was looking for a more elegant way,

Where are core dumps written on Mac?

六月ゝ 毕业季﹏ 提交于 2019-11-28 03:07:54
On Mac OS X, if I send SIGQUIT to my C program, it terminates, but there is no core dump file. Do you have to manually enable core dumps on Mac OS X (how?), or are they written to somewhere else instead of the working directory? xyz It seems they are suppressed by default. Running $ ulimit -c unlimited Will enable core dumps for the current terminal, and it will be placed in /cores/ as core.PID. When you open a new session, it will be set to the default value again. On macOS, your crash dumps are automatically handled by Crash Reporter . You can find backtrace files by executing Console and