kill

killing child processes at parent process exit

情到浓时终转凉″ 提交于 2019-12-06 10:41:33
I'm very new to c and programming and need some help. In c on linux(cygwin) I am required to remove all child processes at exit. I have looked at the other similar questions but can't get it to work. I've tried- atexit(killzombies); //in parent process void killzombies(void) { printf("works"); kill(0, SIGTERM); printf("works"); if (waitpid(-1, SIGCHLD, WNOHANG) < 0) printf("works"); } for some reason, "works" doesn't even print ever. I press ctrl + c to exit. ALSO I have tried- prctl(PR_SET_PDEATHSIG, SIGHUP); //in child process signal(SIGHUP, killMe); void killMe() { printf("works"); exit(1);

Java : How to stop a Thread that's calling a succession of C++ functions using a JNI function?

北城余情 提交于 2019-12-06 07:10:38
So, here is my situation : I've got a Java application that is sending arrays of data to a C++ DLL using a JNI method from a "JavaToCpp" class. Once the C++ DLL have received all the data, it begins performing several actions on it. I'm running the "JavaToCpp" class using a new thread, for my Java interface not to be frozen during the (long) (C++) procedures/subroutines. I implemented two methods to stop the working (C++) procedures/subroutines : The first one "STOP" : is creating a file which is going to be read by the C++ DLL so it can cleanly stop the running procedures/subroutines. The

Can GDB kill a specific thread?

与世无争的帅哥 提交于 2019-12-06 06:45:34
问题 I'm running an application (firefox) and I would like to know if it's possible to use GDB to attach to the process and kill a specific thread . Is there a way to do this? I understand that this operation will probably crash the app. EDIT: In this debugging session, ps -ax revealed that firefox pid is 1328: $ gdb /Applications/Firefox.app/Contents/MacOS/firefox 1328 GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Thu Nov 3 21:59:02 UTC 2011) Copyright 2004 Free Software Foundation, Inc. GDB

How to terminate all [grand]child processes using C# on WXP (and newer MSWindows)

删除回忆录丶 提交于 2019-12-06 06:14:17
问题 Question: How can I determine all processes in the child's Process Tree to kill them? I have an application, written in C# that will: Get a set of data from the server, Spawn a 3rd party utility to process the data, then Return the results to the server. This is working fine. But since a run consumes a lot of CPU and may take as long as an hour, I want to add the ability to have my app terminate its child processes. Some issues that make the simple solutions I've found elsewhere are: My app's

How do I kill a runaway Java process started by Ant?

一个人想着一个人 提交于 2019-12-06 05:07:48
If I start a forked java process from an ant script and kill the ant process, it does not kill the java process. This is the case whether running it from the IDE or from the command line. <target name="myTarget" > <java classname="path.to.MyClass" fork="yes" failonerror="true" maxmemory="128M"> <classpath refid="run" /> </java> </target> Is there a way to link these, so that killing the ant process will kill the java process? I've seen the following Q&A - but this seems to focus on how to kill the java process manually. I don't want to do this, because I have a number of other java

How to halt, kill, stop or close a PycURL request on a stream example given using Twitter Stream

◇◆丶佛笑我妖孽 提交于 2019-12-06 03:42:45
问题 Im currently cURLing the twitter API stream (http://stream.twitter.com/1/statuses/sample.json), so am constantly receiving data. I wish to stop cURLing the stream once i have retrieved X number of objects from it (in the example I give 10 as an arbitrary number). You can see how I have attempted to close the connection in the code below. The code below curling.perform() never executes, due to the fact that it is a continuous stream of data. So I attempted to close the stream in the body

kill signal example

孤人 提交于 2019-12-06 03:07:00
问题 I'm trying this example that I took from: http://www.cs.cf.ac.uk/Dave/C/node24.html: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <signal.h> void sighup(); /* routines child will call upon sigtrap */ void sigint(); void sigquit(); main() { int pid; /* get child process */ if ((pid = fork()) < 0) { perror("fork"); exit(1); } if (pid == 0) { /* child */ printf("\nI am the new child!\n\n"); signal(SIGHUP,sighup); /* set function calls */ signal(SIGINT,sigint); signal

Killing OpenCL Kernels

我只是一个虾纸丫 提交于 2019-12-06 02:39:13
Is there any way to kill a running OpenCL kernel through the OpenCL API? I haven't found anything in the spec. The only solutions I could come up with are 1) periodically checking a flag in the kernel that the host writes to when it wants the kernel to stop, or 2) running the kernel in a separate process and killing the entire process. I don't think either of those are very elegant solutions, and I'm not sure #1 would even work reliably. Eric Bainville No, the OpenCL API doesn't allow to interrupt a running kernel. On some systems, a kernel running for more than a few seconds will be killed by

best way to close hosted process

北慕城南 提交于 2019-12-06 01:02:31
I have process A that starts process B. they communicate in WCF (IAsyncResult APM Pattern), A is client B is service. When Process A dies, i need to close B. I am sending process A id as arg to process b and he does: Process.GetProcessById(processId).WaitForExit(); This is working fine. My question is how to kill process b properly if process a dies ? I tried all the following: Process.GetCurrentProcess().Close(); Process.GetCurrentProcess().Dispose(); Application.Exit(); > its a guiless winform application The only thing that worked was: Process.GetCurrentProcess().Kill(); But isnt killing

PHP - kill exec on client disconnect

三世轮回 提交于 2019-12-05 16:03:06
I have very primitive web front-end for my C++ application. Client (web browser) is enters php site and fills form with parameters. Than (after post submit) php calls exec and application does its work. Application can work longer than minute and requires pretty large amount of RAM. Is there any possibility to detect disconnecting from client (for example closure of tab in web browser). I want to do this, because after disconnecting client will not be able to see result of computations, so I can kill application and free some RAM on server. Thanks for any help or suggestions. DaveRandom As