signals

How to send SIGINT to a remote process over SSH?

青春壹個敷衍的年華 提交于 2019-11-27 02:47:16
问题 I have a program running on a remote machine which expects to receive SIGINT from the parent. That program needs to receive that signal to function correctly. Unfortunately, if I run that process remotely over SSH and send SIGINT, the ssh process itself traps and interrupts rather than forwarding the signal. Here's an example of this behavior using GDB: Running locally: $ gdb GNU gdb 6.3.50-20050815 (Apple version gdb-1344) (Fri Jul 3 01:19:56 UTC 2009) ... This GDB was configured as "x86_64

Checking if errno != EINTR: what does it mean?

我怕爱的太早我们不能终老 提交于 2019-11-27 02:45:53
问题 I've found this piece of code used several times (also a similar one where it's used open() instead of write() ). int c = write(fd, &v, sizeof(v)); if (c == -1 && errno != EINTR) { perror("Write to output file"); exit(EXIT_FAILURE); } Why it is checked if && errno != EINTR here ? Looking for errno on man I found the following text about EINTR , but even if I visited man 7 signal that doesn't enlighten me. EINTR Interrupted function call (POSIX.1); see signal(7). 回答1: Many system calls will

setitimer, SIGALRM & multithread process (linux, c)

ⅰ亾dé卋堺 提交于 2019-11-27 02:45:13
问题 I want to use setitimer() (or less probable, the alarm() ) in multithreaded process in linux 2.6+ with NPTL-enabled libc. Which thread will receive sigalarm (SIGALRM) from kernel? Thanks. 2014-04 update: How should I set the setitimer() in multithreaded program, if I want to write a profiling utility like gperftools's cpuprofile; but in my tool I want to support both dynamically linked programs (so it is possible to inject my own library to init profiling) and statically linked programs

Is it possible to capture a Ctrl+C signal and run a cleanup function, in a “defer” fashion?

◇◆丶佛笑我妖孽 提交于 2019-11-27 02:34:38
I want to capture the Ctrl+C ( SIGINT ) signal sent from the console and print out some partial run totals. Is this possible in Golang? Note: When I first posted the question I was confused about Ctrl+C being SIGTERM instead of SIGINT . Lily Ballard You can use the os/signal package to handle incoming signals. ^C is SIGINT , so you can use this to trap os.Interrupt . c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt) go func(){ for sig := range c { // sig is a ^C, handle it } }() The manner in which you cause your program to terminate and print information is entirely up to you. This

is SIGSEGV delivered to each thread?

試著忘記壹切 提交于 2019-11-27 02:18:42
问题 I have a program in Linux which is multithreaded. There are certain memory areas in which I'm interested to see if they have been written within a certain time period. For that I give only read access to those memory pages and install a signal handler for SIGSEGV. Now my question is, will each thread call the signal handler for itself. Say Thread 1 writes to some forbidden memory area, will it be the one to execute the signal handler? 回答1: First of all Signal dispositions are process-wide;

About the ambiguous description of sigwait()

爱⌒轻易说出口 提交于 2019-11-27 02:17:59
问题 If no signal in set is pending at the time of the call, the thread shall be suspended until one or more becomes pending. The signals defined by set shall have been blocked at the time of the call to sigwait(); otherwise, the behavior is undefined. The effect of sigwait() on the signal actions for the signals in set is unspecified. This is really ambiguous ,what's the difference between pending and block here? And its conclusion on how to choose between sigwait and sigaction is not clear at

True timeout on LWP::UserAgent request method

六月ゝ 毕业季﹏ 提交于 2019-11-27 02:15:05
问题 I am trying to implement a request to an unreliable server. The request is a nice to have, but not 100% required for my perl script to successfully complete. The problem is that the server will occasionally deadlock (we're trying to figure out why) and the request will never succeed. Since the server thinks it is live, it keeps the socket connection open thus LWP::UserAgent's timeout value does us no good what-so-ever. What is the best way to enforce an absolute timeout on a request? FYI,

How to prevent SIGPIPE or prevent the server from ending?

只谈情不闲聊 提交于 2019-11-27 02:14:43
问题 A quite standard C++ TCP server program using pthreads , bind , listen and accept . I have the scenario that the server ends (read: crashes) when I kill a connected client. The reason for the crash is that the write() call on the file fails, thus the program receives a SIGPIPE. And I guess, this makes the server exit. I thought, "of course, unhandled signal means exit", so let's use signal() : signal(SIGPIPE, SIG_IGN); because, taken from man 2 write : EPIPE fd is connected to a pipe or

How can I retrieve the signal strength of nearby wireless LAN networks on Windows using Python?

不想你离开。 提交于 2019-11-27 01:59:02
问题 How can I retrieve the signal strength of nearby wireless LAN networks on Windows using Python? I would like to either show or graph the values. 回答1: If you are on Windows , you probably want to use the WLAN API , which provides the 'WlanGetAvailableNetworkList()' function (see the API docs for usage). I am not aware of any python wrappers for WLANAPI.DLL so you may have to wrap it yourself using ctypes. I have a preliminary script that does this ( works-for-me ), but it may be crufty. You'll

Paramiko and exec_command - killing remote process?

陌路散爱 提交于 2019-11-27 01:54:20
问题 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',