Tag: 杀死

如何从系统函数调用中删除后台进程

如何终止使用C语言的系统函数调用执行的后台进程。 例如,我有一个编译的应用程序调用“fooprocess”。 然后我想编写一个程序,使用系统函数在后台执行fooprocess应用程序,请在下面的代码中查看, const char app[] = “fooprocess &”; system(app); 如您所见,有一个“&”字符,以便我可以在后台运行fooprocess应用程序。 我该怎样杀死这个过程? 非常感谢。

C- SIGUSR1究竟是什么语法

当我在kill()或signal()函数中使用SIGUSR1时,它在做什么? 这是一个宏吗? 我读到它是用户定义的,但它在哪里定义? 我可以制作一个SIGUSR10(或以编程方式制作不同信号类型的“arrays”)吗?

在父进程退出时终止子进程

我对c和编程很新,需要一些帮助。 在Linux上的c(cygwin)我需要在退出时删除所有子进程。 我看过其他类似的问题,但无法让它发挥作用。 我试过了- atexit(killzombies); //in parent process void killzombies(void) { printf(“works”); kill(0, SIGTERM); printf(“works”); if (waitpid(-1, SIGCHLD, WNOHANG) < 0) printf("works"); } 由于某种原因,“作品”甚至不打印。 我按ctrl + c退出。 我也尝试过 – prctl(PR_SET_PDEATHSIG, SIGHUP); //in child process signal(SIGHUP, killMe); void killMe() { printf(“works”); exit(1); } 但是因为我正在使用cygwin,当我#include ,cygwin说它找不到文件或目录,我不知道要为它安装什么包。 此外,如果我的prctl()函数工作,会杀死所有的僵尸吗? 我的程序是客户端服务器,我的服务器forks()来处理每个客户端。 我想在服务器关闭时不留下任何剩余的僵尸。

警告:隐式声明函数’kill’

我正在制作这些内容: #include #include #include #include 但仍然得到这个警告。

如何在从“killall”或“kill -p pid”接收kill信号时退出程序之前执行处理函数?

我有以下代码: #include #include #include pthread_t test_thread; void *thread_test_run (void *v) { int i=1; while(1) { printf(“into thread %d\r\n”,i); i++; sleep(1); } return NULL } int main() { pthread_create(&test_thread, NULL, &thread_test_run, NULL); sleep (20); pthread_cancel(test_thread); sleep(100); // In this period (before the finish of myprogram), // I execute killall to kill myprogram // I want to […]

如何用C杀死管理线程?

我有以下代码。 构建应用程序是myprogram。 如果我启动myprogram然后killall myprogram,然后我立即启动myprogram,然后myprogram崩溃。 崩溃原因是由于第一次启动创建的管理线程在第二次启动之前未正确清除。 所以在第二次启动时,myprogram试图用pthread创建线程,旧的线程管理还没有被删除,所以它会导致崩溃。 有没有办法在我第一次启动时或在我第二次使用C启动时开始杀死管理线程? #include #include #include pthread_t test_thread; void *thread_test_run (void *v) { int i=1; while(1) { printf(“into thread %d\r\n”,i); i++; sleep(1); } return NULL } int main() { // ps aux | grep myprogram —> show 1 myprogram (1 for the main application) pthread_create(&test_thread, NULL, &thread_test_run, NULL); // ps aux […]

杀死一个以popen开始的进程

在使用popen打开管道进程后,有没有办法杀死已启动的进程? (使用pclose不是我想要的,因为它会等待进程完成,但我需要杀死它。)