kill

Is SIGSEGV special when generated by `kill`?

孤人 提交于 2019-12-01 10:16:12
问题 I know that SIGSEGV can't be ignored when the kernel uses it to report a memory access violation. But if I install a signal handler for SIGSEGV that does nothing, and then another process uses kill to send me that signal, will this behave the same as if I had used a "normal" signal (like SIGUSR1 ) instead? 回答1: I have function that receive signal SIGSEGV but do nothing with it, does it mean that signal is ignored ? Yes, you caught the signal SIGSEGV and do nothing in handler, control returns.

Android application Exit for home screen

梦想的初衷 提交于 2019-12-01 09:22:43
问题 I have develop android application,there I have Exit button in menu option.I want exit application and go to home screen when I press exit button. for that I have used following methods 1. System.exit(0) 2. finish() 3. android.os.Process.killProcess(android.os.Process.myPid()) 4. System.runFinalizersOnExit(true); these all methods direct to application my first page not to home screen.so what should I do for this?? please help me 回答1: Firstly close in an android application is frowned upon

How to kill a Thread with Objective C?

柔情痞子 提交于 2019-12-01 07:42:26
问题 I have a call to a third-party C++ library which I have put into its own thread (currently using NSThread). I would like to give the user the ability to stop the execution of that thread. (I am well aware of all the problems this might cause, but I still wish to do so.) According to Apple's Thread Programming Guide, there are possibilities in Cocoa to do so. Is this true for the iPhone, too, or do I have to rely on Posix threads to accomplish my goal? Cheers MrMage 回答1: The correct way to

Bash script kill background (grand)children on Ctrl+C

时光毁灭记忆、已成空白 提交于 2019-12-01 06:07:53
I have a Bash script (Bash 3.2, Mac OS X 10.8) that invokes multiple Python scripts in parallel in order to better utilize multiple cores. Each Python script takes a really long time to complete. The problem is that if I hit Ctrl+C in the middle of the Bash script, the Python scripts do not actually get killed. How can I write the Bash script so that killing it will also kill all its background children? Here's my original "reduced test case". Unfortunately I seem to have reduced it so much that it no longer demonstrates the problem; my mistake. set -e cat >work.py <<EOF import sys, time for i

C++ Sending a simple signal in Windows

只愿长相守 提交于 2019-12-01 04:55:23
问题 is there an equivalent to the function kill() on Windows? int kill(pid_t pid, int sig); If not, would it be possible to test if a process is running based on its PID? Thanks 回答1: Windows doesn't have signals in the unix sense. You can use OpenProcess to check if a process exists - If it succeeds, or fails with an access error, then the process exists. bool processExists(DWORD ProcessID) { HANDLE hProcess = OpenProcess(SYNCHRONIZE, FALSE, ProcessID); if (hProcess != NULL) { CloseHandle

How to kill process in c++, knowing only part of its name

我只是一个虾纸丫 提交于 2019-11-30 22:42:44
Some time ago I needed to write c++ code to kill some process. In my main program I run large CAE-system package with system("...") with different filename strings on input. CAE-software creates many processes, that contain in process name string filename ). Some of the CAE-processes worktime > max_time , than I need to shut them down: //filename contains part of CAE-process name string s="/bin/kill -9 `ps aux | grep "+filename+" | awk {'print $2'}`"; system(s.c_str()); The output was: Usage: kill pid ... Send SIGTERM to every process listed. kill signal pid ... Send a signal to every process

Linux, waitpid, WNOHANG, child process, zombie

人走茶凉 提交于 2019-11-30 19:31:51
问题 I running my program as daemon. Father process only wait for child process, when it is dead unexpected, fork and wait again. for (; 1;) { if (fork() == 0) break; int sig = 0; for (; 1; usleep(10000)) { pid_t wpid = waitpid(g->pid[1], &sig, WNOHANG); if (wpid > 0) break; if (wpid < 0) print("wait error: %s\n", strerror(errno)); } } But when child process being killed with -9 signal, the child process goes to zombie process. waitpid should return the pid of child process immediately! But

Android kill process [duplicate]

匆匆过客 提交于 2019-11-30 18:30:42
This question already has an answer here: How to kill an application with all its activities? [duplicate] 6 answers How to kill whole application in onne single click.. finish() is not working?? it redirects to tha previous activity...pls guide me. public void onClick(View arg0) { // TODO Auto-generated method stub WallpaperManager wp = WallpaperManager .getInstance(getApplicationContext()); try { Display d = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay(); int width = d.getWidth(); int height = d.getHeight(); wp.setBitmap(b1); } catch (IOException e) { Log.e(

How to kill process in c++, knowing only part of its name

雨燕双飞 提交于 2019-11-30 18:02:12
问题 Some time ago I needed to write c++ code to kill some process. In my main program I run large CAE-system package with system("...") with different filename strings on input. CAE-software creates many processes, that contain in process name string filename ). Some of the CAE-processes worktime > max_time , than I need to shut them down: //filename contains part of CAE-process name string s="/bin/kill -9 `ps aux | grep "+filename+" | awk {'print $2'}`"; system(s.c_str()); The output was: Usage:

How to kill the management thread with C?

夙愿已清 提交于 2019-11-30 16:07:52
I have the following code. the build application is myprogram. If I launch myprogram and then killall myprogram and immediately after that I launch again myprogram then myprogram crash. the crash cause is due to that the management thread created by the first launch is not properly cleared before the second launch. so in the second launch whent myprogram try to create thread with the pthread and the old thread management is not removed yet so it causes a crash. Are there a way to kill the management thread at the end of my first launch or at the beginning of my second launch with C ? #include