pid

killing Parent process along with child process using SIGKILL

懵懂的女人 提交于 2019-12-21 17:24:53
问题 I am writing one shell script in which I have parent process and it has child processes which are created by sleep & command. Now I wish to kill the parent process so that the child process will be also killed. I was able to do that this with below command: trap "kill $$" SIGINT trap 'kill -HUP 0' EXIT trap 'kill $(jobs -p)' EXIT These commands are working with kill [parent_process_ID] commands but if I use kill -9 [parent_process_ID] then only the parent process will be killed. Please guide

17、fork函数

只谈情不闲聊 提交于 2019-12-21 14:26:39
1、定义 #include <unistd.h> #include<sys/types.h> pid_t fork( void ); pid_t 是一个宏定义,其实质是 int ,被定义在 #include<sys/types.h> 中 返回值:若成功调用一次则返回两个值,子进程返回 0 ,父进程返回子进程 ID ;否则,出错返回 -1 2、函数说明: 一个现有进程可以调用 fork 函数创建一个新进程。由 fork 创建的新进程被称为子进程( child process )。 fork 函数被调用一次但返回两次。两次返回的唯一区别是子进程中返回 0 值而父进程中返回子进程 ID 。 子进程是父进程的副本, 它将获得父进程数据空间、堆、栈等资源的副本 。注意,子进程持有的是上述存储空间的“副本”,这意味着父子进程间不共享这些存储空间。 File locks and pending signals are not inherited. 【 3 】 If the call to fork() is executed successfully, Unix will ① make two identical copies of address spaces, one for the parent and the other for the child. ② Both processes

How to get the process ID of the current Excel instance, through VBA, without using the caption?

孤街醉人 提交于 2019-12-21 09:23:54
问题 How can I get the process ID of the current Excel instance that my VBA code is running in? I don't want to asking for it by the name in the caption, which causes problems when I have two or more Excel instances with the same caption. 回答1: You can use this method to get the current process id. Declare Function GetCurrentProcessId Lib "kernel32" () As Long This page has a good overview of exactly how you can do it in various versions of excel. 回答2: As a vba n00b, some other things I did not

三个实例演示 Java Thread Dump 日志分析

微笑、不失礼 提交于 2019-12-21 07:40:01
企业级应用开发中经常会遇到以下问题,可以使用工具对JVM进行监管,以便及时查找问题所在。   内存不足OutOfMemory(大对象没有gc等),内存泄露;   线程死锁,线程数过多;   锁争用(Lock Contention),资源未及时释放(数据库);   Java进程CPU消耗过高. 一、Java自带工具   Java安装目录的bin文件加下有一些工具可以用来监控JVM性能,如jconsole、jvisualvm、jmap、jps、jstack、jhat、jstat等。 1. jconsole   jconsole可以监控Java应用程序(如jar应用、tomcat等),但被监视的应用程序必须和jconsole是用同一个用户运行的。jvisualvm的使用和jconsole类似。 本地监控 : jconsole pid 远程监控 : jconsole [ hostname:portNum ] 使用远程监控需要配置jmx代理信息,修改Tomcat的bin目录下的catalina.bat。 set JAVA_OPTS= %JAVA_OPTS% -Djava.rmi.server.hostname=HostIP set JAVA_OPTS= %JAVA_OPTS% -Dcom.sun.management.jmxremote.port=8888 set JAVA_OPTS=

查看jvm常用命令

柔情痞子 提交于 2019-12-21 07:39:36
jinfo :可以输出并修改运行时的java 进程的opts。 jps :与unix上的ps类似,用来显示本地的java进程,可以查看本地运行着几个java程序,并显示他们的进程号。 jstat :一个极强的监视VM内存工具。可以用来监视VM内存内的各种堆和非堆的大小及其内存使用量。 jmap :打印出某个java进程(使用pid)内存内的所有'对象'的情况(如:产生那些对象,及其数量)。 jconsole :一个java GUI监视工具,可以以图表化的形式显示各种数据。并可通过远程连接监视远程的服务器VM。 详细:在使用这些工具前,先用JPS命令获取当前的每个JVM进程号,然后选择要查看的JVM。 ---------------------------------------------------------------------- jstat工具特别强大,有众多的可选项,详细查看堆内各个部分的使用量,以及加载类的数量。使用时,需加上查看进程的进程id,和所选参数。以下详细介绍各个参数的意义。 jstat -class pid:显示加载class的数量,及所占空间等信息。 jstat -compiler pid:显示VM实时编译的数量等信息。 jstat -gc pid:可以显示gc的信息,查看gc的次数,及时间。其中最后五项,分别是young gc的次数,young

Memory used by a process under mac os x

放肆的年华 提交于 2019-12-21 04:25:35
问题 Given a PID, how can I get the memory currently used by a process ? Specifically I am looking for: The private physical memory (RAM) used by the process The swap space used by the process But I am not interested in mapped files and shared memory. In short, I would like to determine how much memory (RAM and swap) would be freed by terminating the PID. 回答1: You can use Mach's task_info call to find this information. Here is code which works on OS X v10.9, and which gets the virtual process size

wait和waitpid详解

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-21 00:23:48
前记:恩,很多文章都是转载的,有的时候也没有附上别人的链接,这样是不好,但是就像是学习笔记做摘抄一样,我的博文不会商用,如果有商用那一天,一定保证好著作权。 学习本就是一个相互借鉴和模仿的过程。恩,大家一起学习,一起成长,才能不断进步! 关于wait和waitpid的区别,之前在严冰的linux程序设计书里只是简单介绍了一下,今天看一位有名的博主的UNIX网络编程的读书笔记的时候,发现自己对于wait和waitpid还是不理解。 wait()就是得到子进程的返回码,等于就是为子进程“收尸”,否则子进程会变僵尸进程(关于僵尸和孤儿进程的区别,之前有总结过),如果父进程结束了,init进程会为僵尸进程收尸的。 SIGCHLD信号处理函数: 进程一章讲过用wait和waitpid函数清理僵尸进程,父进程可以阻塞等待子进程结束,也可以非阻塞地查询是否有子进程结束等待清理(也就是轮询的方式)。采用第一种方式,父进程阻塞了就不能处理自己的工作了;采用第二种方式,父进程在处理自己的工作的同时还要记得时不时地轮询一下,程序实现复杂。 其实,子进程在终止时会给父进程发SIGCHLD信号,该信号的默认处理动作是忽略,父进程可以自定义SIGCHLD信号的处理函数,这样父进程只需专心处理自己的工作,不必关心子进程了,子进程终止时会通知父进程,父进程在信号处理函数中调用wait清理子进程即可。 事实上

系统调用wait()

与世无争的帅哥 提交于 2019-12-21 00:21:15
  进程一旦调用了 wait,就 立即阻塞自己,由wait自动分析是否当前进程的某个子进程已经退出 ,如果让它找到了这样一个已经变成僵尸的子进程,wait 就会收集这个子进程的信息, 并把它彻底销毁后返回;如果没有找到这样一个子进程,wait就会一直阻塞在这里,直到有一个出现为止。 头文件   #include<sys/types.h>   #include<sys/wait.h> 定义函数   pid_t wait (int * status); 函数说明   wait()会暂时停止目前进程的执行,直到有信号来到或子进程结束。如果在调用wait()时子进程已经结束,则wait()会立即返回子进程结束状态值。子进程的结束状态值会由参数status 返回,而子进程的进程识别码也会一快返回。如果不在意结束状态值,则参数status 可以设成NULL。子进程的结束状态值请参考waitpid()。 返回值   如果执行成功则返回子进程识别码(PID),如果有错误发生则返回-1。失败原因存于errno 中。 范例一 #include<stdlib.h> #include<unistd.h> #include<sys/types.h> #include<sys/wait.h> int main() { pid_t pid; int status,i; if(fork()= =0){

wait和waitpid函数

北城余情 提交于 2019-12-21 00:20:45
来源:http://hohahohayo.blog.163.com/blog/static/120816010200971210230362/ wait(等待子进程中断或结束) 表头文件 #include<sys/types.h> #include<sys/wait.h>   定义函数 pid_t wait (int * status);   函数说明:   wait()会暂时停止目前进程的执行,直到有信号来到或子进程结束。   如果在调用 wait()时子进程已经结束,则 wait()会立即返回子进程结束状态值。   子进程的结束状态值会由参数 status 返回,而子进程的进程识别码也会一起返回。   如果不在意结束状态值,则参数 status 可以设成 NULL。   子进程的结束状态值请参考 waitpid( )     如果执行成功则返回子进程识别码(PID) ,如果有错误发生则返回返回值-1。失败原因存于 errno 中。 waitpid(等待子进程中断或结束)   表头文件 #include<sys/types.h> #include<sys/wait.h>   定义函数 pid_t waitpid(pid_t pid,int * status,int options);   函数说明:   waitpid()会暂时停止目前进程的执行,直到有信号来到或子进程结束。  

springBoot获取ajax传来的list实体类,数据转换json出现字段值为空问题

为君一笑 提交于 2019-12-20 19:42:52
从ajax获取的list集合 用List<Product> list= JSON.parseArray(bb.toString(),Product.class); 转换后发现PId的值为null 后来问朋友才知道,原来是实体类的get/set方法有问题,set方法是setpId,因为json转换的原理是拼接方法名(get/set) +反射取实体类属性名 (PId),即setPId,这样就和下面的set方法不一样就会导致set为null 解决办法: 按照命名规范把 public void setpId(Integer pId) { this.pId = pId; } 改为: public void setPId(Integer pId) { this.pId = pId; } 最后取得了: 来源: CSDN 作者: JU人的肩膀 链接: https://blog.csdn.net/weixin_41043652/article/details/103630898