Questions tagged [terminate]

For questions regarding the termination of processes, threads, and sessions.

874 questions
831
votes
29 answers

Is there any way to kill a Thread?

Is it possible to terminate a running thread without setting/checking any flags/semaphores/etc.?
Sudden Def
  • 8,541
  • 3
  • 16
  • 8
204
votes
35 answers

How to stop C++ console application from exiting immediately?

Lately, I've been trying to learn C++ from this website. Unfortunately whenever I try to run one of the code samples, I see that program open for about a half second and then immediately close. Is there a way to stop the program from closing…
Adam P
  • 4,345
  • 6
  • 27
  • 40
126
votes
17 answers

How to stop/terminate a python script from running?

I wrote a program in IDLE to tokenize text files and it starts to tokeniza 349 text files! How can I stop it? How can I stop a running Python program?
MACEE
  • 1,465
  • 4
  • 11
  • 10
122
votes
4 answers

SBT stop run without exiting

How do you terminate a run in SBT without exiting? I'm trying CTRL+C but it exits SBT. Is there a way to only exit the running application while keeping SBT open?
dsg
  • 12,504
  • 19
  • 64
  • 109
83
votes
5 answers

Self-Terminating AWS EC2 Instance?

Is there a way that Amazon Web Services EC2 instances can be self terminating? Does Amazon have anything that allows an instance to terminate itself ("Hara-Kiri") after running for more than say an hour? I could change the scripts on the running…
Steve3p0
  • 1,762
  • 4
  • 18
  • 25
66
votes
13 answers

How to terminate a Xamarin application?

How to terminate a Xamarin application from any of the activities? I have tried both System.Environment.Exit(0) and System.Environment.Exit(1) as well as Finish() and killing all the activities. It still opens one blank page with default activity…
Nik
  • 661
  • 1
  • 5
  • 4
54
votes
4 answers

PHP - exit or return which is better?

I would like to know in the following case which is a better option: In the PHP script, if the $fileSize variable is larger than 100, I stop the script; Case I: 100 ) { $results['msg'] = 'fileSize is too big!'; echo…
q0987
  • 31,246
  • 61
  • 222
  • 356
50
votes
4 answers

Why not to start a thread in the constructor? How to terminate?

I am learning how to use threads in Java. And I wrote a class that implements Runnable to run concurrently to another thread. The main thread handles listening to the serial port where as the second thread will handle sending data to that same…
Zac
  • 2,059
  • 8
  • 32
  • 40
41
votes
11 answers

Stopping Excel Macro executution when pressing Esc won't work

I'm running excel 2007 on XP. Is there a way to stop a macro from running during its execution other than pressing escape? Usually if I think I created an infinate loop or otherwise messed something up I hit escape and it throws an error but the…
ptpaterson
  • 7,731
  • 4
  • 24
  • 33
33
votes
3 answers

Amazon EC2 autoscaling down with graceful shutdown?

We're looking at using EC2 autoscaling to deal with spikes in load. In our case we want to scale up instances based on an SQS queue size and then down scale with the queue size gets back under control. Each SQS message defines a potentially long…
danw
  • 1,308
  • 1
  • 15
  • 15
32
votes
11 answers

Process.HasExited returns true even though process is running?

I have been observing that Process.HasExited sometimes returns true even though the process is still running. My code below starts a process with name "testprogram.exe" and then waits for it to exit. The problem is that sometimes I get thrown the…
johnrl
  • 843
  • 3
  • 13
  • 18
31
votes
4 answers

How to perform an async operation on exit

I've been trying to perform an asynchronous operation before my process is terminated. Saying 'terminated' I mean every possibility of termination: ctrl+c Uncaught exception Crashes End of code Anything.. To my knowledge the exit event does that…
Kesem David
  • 1,879
  • 3
  • 19
  • 44
27
votes
6 answers

Do IDisposable objects get disposed of if the program is shut down unexpectedly?

What happens if the program exits unexpectedly (either by exception or the process is terminated)? Are there any situations like this (or otherwise) where the program will terminate, but IDisposable objects won't be properly disposed of? The reason…
JSideris
  • 4,545
  • 2
  • 27
  • 49
25
votes
7 answers

How to properly stop a multi-threaded .NET windows service?

I have a windows service written in C# that creates a truck load of threads and makes many network connections (WMI, SNMP, simple TCP, http). When attempting to stop the windows service using the Services MSC snap-in, the call to stop the service…
Mark
  • 4,641
  • 11
  • 46
  • 78
24
votes
4 answers

ruby timeouts and system commands

I have a ruby timeout that calls a system (bash) command like this.. Timeout::timeout(10) { `my_bash_command -c12 -o text.txt` } but I think that even if the ruby thread is interrupted, the actual command keeps running in the background.. is it…
luca
  • 10,961
  • 13
  • 61
  • 100
1
2 3
58 59