control-c

Powershell AcceptTcpClient() cannot be interrupted by Ctrl-C

£可爱£侵袭症+ 提交于 2020-07-05 12:55:48
问题 I am writing a simple TCP/IP server using Powershell. I notice that Ctrl-C cannot interrupt the AcceptTcpClient() call. Ctrl-C works fine after the call though. I have searched around, nobody reported similar problem so far. The problem can be repeated by the following simple code. I am using Windows 10, latest patch, with the native Powershell terminal, not Powershell ISE. $listener=new-object System.Net.Sockets.TcpListener([system.net.ipaddress]::any, 4444) $listener.start() write-host

Powershell AcceptTcpClient() cannot be interrupted by Ctrl-C

时光怂恿深爱的人放手 提交于 2020-07-05 12:55:27
问题 I am writing a simple TCP/IP server using Powershell. I notice that Ctrl-C cannot interrupt the AcceptTcpClient() call. Ctrl-C works fine after the call though. I have searched around, nobody reported similar problem so far. The problem can be repeated by the following simple code. I am using Windows 10, latest patch, with the native Powershell terminal, not Powershell ISE. $listener=new-object System.Net.Sockets.TcpListener([system.net.ipaddress]::any, 4444) $listener.start() write-host

Interrupting Python raw_input() in a child thread with ^C/KeyboardInterrupt

≯℡__Kan透↙ 提交于 2019-12-30 18:29:50
问题 In a multithreaded Python program, one thread sometimes asks for console input using the built-in raw_input(). I'd like to be able to be able to close the program while at a raw_input prompt by typing ^C at the shell (i.e., with a SIGINT signal). However, when the child thread is executing raw_input, typing ^C does nothing -- the KeyboardInterrupt is not raised until I hit return (leaving raw_input). For example, in the following program: import threading class T(threading.Thread): def run

Delegate signal handling to a child process in python

怎甘沉沦 提交于 2019-12-19 19:40:19
问题 How can I run a command from a python script and delegate to it signals like Ctrl+C ? I mean when I run e.g: from subprocess import call call(["child_proc"]) I want child_proc to handle Ctrl+C 回答1: I'm guessing that your problem is that you want the subprocess to receive Ctrl-C and not have the parent Python process terminate? If your child process initialises its own signal handler for Ctrl-C (SIGINT) then this might do the trick: import signal, subprocess old_action = signal.signal(signal

Handling CTRL-C in dummy shell

余生颓废 提交于 2019-12-13 02:50:50
问题 I'm writing a dummy shell that should not terminate when the user types ctrl-C but should just generate a new prompt line. Currently, my shell does not terminate when I type ctrl-C but it still does not print the new prompt line. Do you know why this is the case and how I can fix this? My code is below: #include <stdlib.h> #include <stdio.h> #include <errno.h> #include <string.h> #include <unistd.h> #include <sys/wait.h> #include <signal.h> #define BUFFER_SIZE 1<<16 #define ARRAY_SIZE 1<<16

Need to highlight and copy text from google doc viewer to clipboard

醉酒当歌 提交于 2019-12-12 05:24:57
问题 I have to create a process where a document is shown to the user and the user can highlight text and copy (and eventually paste) the text from some portions of the document. I am using google doc viewer in an iframe (since I need a universal doc viewer that's free - although I'm open to other ideas on viewers). Google doc viewer does what I need but it seems that I don't have access to the internals of the iframe to get the highlighted contents. I've looked at many links related to triggering

How to kill a scan operation in hbase shell without Ctrl-C

徘徊边缘 提交于 2019-12-04 21:22:29
问题 Sometimes when I run a scan '<tablename> . I see a continuous flood of data being printed because the table is big. I want to kill the process that print the data. Is there a way to do it other than Ctrl-C ? because Ctrl-C kills the shell process and I don't want to exit the shell. 回答1: You could use scan with LIMIT to limit the scan output on shell : scan 'table', LIMIT => 5 This will show you only 5 rows. You could also press ctlr+s to hold the scan, if you have done a full scan and want to

why socket on the receiving peer keep receiving '' infinitely when I use “control-c” to close the socket on the sending peer

╄→гoц情女王★ 提交于 2019-12-02 23:43:31
问题 I'm a newbie to socket programming, I know it's a bad habit to close socket using "control-c", but why socket on the receiving peer keeps receiving '' infinitely after I use "control-c" to close the sending process? shouldn't the socket on the sending peer be closed after "control-c" to exit the process? Thanks! 回答1: I know it's a bad habit to close socket using "control-c" That closes the entire process, not just a socket. why socket on the receiving peer keeps receiving '' infinitely after

Interrupting Python raw_input() in a child thread with ^C/KeyboardInterrupt

陌路散爱 提交于 2019-12-01 17:07:34
In a multithreaded Python program, one thread sometimes asks for console input using the built-in raw_input() . I'd like to be able to be able to close the program while at a raw_input prompt by typing ^C at the shell (i.e., with a SIGINT signal). However, when the child thread is executing raw_input, typing ^C does nothing -- the KeyboardInterrupt is not raised until I hit return (leaving raw_input). For example, in the following program: import threading class T(threading.Thread): def run(self): x = raw_input() print x if __name__ == '__main__': t = T() t.start() t.join() Typing ^C does

Catching Ctrl+C in Java

断了今生、忘了曾经 提交于 2019-11-26 08:05:24
问题 Is it possible to catch the Ctrl + C signal in a java command-line application? I\'d like to clean up some resources before terminating the program. 回答1: You can attach a shutdown hook to the VM which gets run whenever the VM shuts down: The Java virtual machine shuts down in response to two kinds of events: The program exits normally, when the last non-daemon thread exits or when the exit (equivalently, System.exit) method is invoked, or The virtual machine is terminated in response to a