termination

Detect file creation with watchdog

北城余情 提交于 2019-12-20 10:25:09
问题 I am trying to detect when a file with a given name is created in a directory. I am doing it thanks to watchdog. The creation is correctly detected but I don't know how to terminate the application properly once the detection is done. My piece of code is the following: #!/usr/bin/env python # -*- coding: utf-8 -*- import logging import sys import time from watchdog.events import FileSystemEventHandler from watchdog.observers import Observer logging.basicConfig(level=logging.ERROR) class

detect program termination (C, Windows)

拥有回忆 提交于 2019-12-18 11:35:03
问题 I have a program that has to perform certain tasks before it finishes. The problem is that sometimes the program crashes with an exception (like database cannot be reached, etc). Now, is there any way to detect an abnormal termination and execute some code before it dies? Thanks. code is appreciated. 回答1: 1. Win32 The Win32 API contains a way to do this via the SetUnhandledExceptionFilter function, as follows: LONG myFunc(LPEXCEPTION_POINTERS p) { printf("Exception!!!\n"); return EXCEPTION

detect program termination (C, Windows)

左心房为你撑大大i 提交于 2019-12-18 11:34:52
问题 I have a program that has to perform certain tasks before it finishes. The problem is that sometimes the program crashes with an exception (like database cannot be reached, etc). Now, is there any way to detect an abnormal termination and execute some code before it dies? Thanks. code is appreciated. 回答1: 1. Win32 The Win32 API contains a way to do this via the SetUnhandledExceptionFilter function, as follows: LONG myFunc(LPEXCEPTION_POINTERS p) { printf("Exception!!!\n"); return EXCEPTION

Guaranteed file deletion upon program termination (C/C++)

最后都变了- 提交于 2019-12-17 23:06:43
问题 Win32's CreateFile has FILE_FLAG_DELETE_ON_CLOSE , but I'm on Linux. I want to open a temporary file which will always be deleted upon program termination. I could understand that in the case of a program crash it may not be practical to guarantee this, but in any other case I'd like it to work. I know about RAII. I know about signals. I know about atexit(3) . I know I can open the file and delete it immediately and the file will remain accessible until the file descriptor is closed (which

How to stop/terminate a python script from running?

a 夏天 提交于 2019-12-17 17:59:29
问题 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? 回答1: To stop your program, just press Control + C . 回答2: You can also do it if you use the exit() function in your code. More ideally, you can do sys.exit() . sys.exit() might terminate Python even if you are running things in parallel through the multiprocessing package. 回答3: If your program is running at an interactive console, pressing CTRL

Assisting Agda's termination checker

余生颓废 提交于 2019-12-17 15:55:19
问题 Suppose we define a function f : N \to N f 0 = 0 f (s n) = f (n/2) -- this / operator is implemented as floored division. Agda will paint f in salmon because it cannot tell if n/2 is smaller than n. I don't know how to tell Agda's termination checker anything. I see in the standard library they have a floored division by 2 and a proof that n/2 < n. However, I still fail to see how to get the termination checker to realize that recursion has been made on a smaller subproblem. 回答1: Agda's

How to prevent a windows application from being killed/terminate or stop [closed]

烂漫一生 提交于 2019-12-13 08:36:19
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . I have a windows c++ application which runs under the normal (non-admin) user. I want that no user should be able to close/stop/terminate this application by any means. Is there any active directory group policy available to achieve this or I need to do some programming for the

Why does this 'with' block spoil the totality of this function?

大兔子大兔子 提交于 2019-12-12 17:50:38
问题 I'm trying to compute parity together with the floor of the half, over natural numbers: data IsEven : Nat -> Nat -> Type where Times2 : (n : Nat) -> IsEven (n + n) n data IsOdd : Nat -> Nat -> Type where Times2Plus1 : (n : Nat) -> IsOdd (S (n + n)) n parity : (n : Nat) -> Either (Exists (IsEven n)) (Exists (IsOdd n)) I tried going with the obvious implementation of parity : parity Z = Left $ Evidence _ $ Times2 0 parity (S Z) = Right $ Evidence _ $ Times2Plus1 0 parity (S (S n)) with (parity

launching python script process from another script on Ubuntu: how to track status?

假如想象 提交于 2019-12-11 20:21:45
问题 I launch one Python script out of another one on an Amazon EC2 Ubuntu instance using a command: os.system(call) where call has the form "./script2.py arg1 arg2 arg3" I've noticed that from time to time script2.py somehow terminates prematurely. I have some logging statements in it but they don't show what's going on. So my questions are: I read that system() returns some sort of exit status. What's the best test to distinguish between a normal and abnormal termination? That is, I only want to

Proving Termination in Coq

我的未来我决定 提交于 2019-12-11 03:02:59
问题 How can I prove termination for size_prgm ? I tried, but can't come up with a well founded relation to pass to Fix . Inductive Stmt : Set := | assign: Stmt | if': (list Stmt) -> (list Stmt) -> Stmt. Fixpoint size_prgm (p: list Stmt) : nat := match p with | nil => 0 | s::t => size_prgm t + match s with | assign => 1 | if' b0 b1 => S (size_prgm b0 + size_prgm b1) end end. 回答1: The termination oracle is quite better than what it used to be. Defining a function sum_with using fold_left and