pid

Find the pid of a java process under Linux

China☆狼群 提交于 2019-11-29 06:10:14
问题 Hello I am using MPJ library in java program for Pagerank algorithm. I compile it by javac -cp .:$MPJ_HOME/lib/mpj.jar MpiPageRank.java and run by mpjrun.sh -np 2 MpiPageRank where -np is number of process Now i have to find its pid ps -ef|grep java like mpjrun.sh -np 2 MpiPageRank & sleep 2 ps -ef | grep java I get pnewaska 27866 27837 99 21:28 pts/45 00:00:09 java -cp /u/pnewaska/mpj-v0_38/lib/smpdev.jar:/u/pnewaska/mpj-v0_38/lib/xdev.jar:/u/pnewaska/mpj-v0_38/lib/mpjbuf.jar:/u/pnewaska/mpj

Java: Get a process given a pid

独自空忆成欢 提交于 2019-11-29 03:43:59
Say I have a current running process known, how can I turn this into a Process object in Java? The process is already running, so I don't want to spawn off another one, I just want to encapsulate it into a Process object that I can use within the java code. Something along the lines of: int pid = getPid(); Process proc = magicGetProcess(pid); thanks I don't think this is possible using only the builtin library. AFAIK, it is already non-trivial to get the running process' own PID (see the feature request and alternate mechanisms ). A quick look at the java.lang.Process class shows that you

java树形结构工具类

给你一囗甜甜゛ 提交于 2019-11-29 03:26:51
一.树形结构数据一般都是以子父id的形式存在数据库中,查询的时候只是带有子id和parent_id的List集合 并不是树形结构,所以我们现在要将普通的List集合转换为树结构数据(本工具类扩展操作树结构数据方法) 1.工具类(TreeNodeUtil) 代码示例: package com.ywb.pms.util.tree; import com.alibaba.druid.util.StringUtils; import com.ywb.pms.vo.BaseTreeNode; import org.apache.commons.collections.CollectionUtils; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; /** * @Author: ywb * @Date: 2019/8/19 14:32 * @Version 1.0 */ public class TreeNodeUtil { /** * 获取关联父节点数据集合列表 * 由对应的子节点到根节点(root) * * @param id 要搜索对应父节点节点的id *

c++并发编程之进程创建

妖精的绣舞 提交于 2019-11-29 03:24:52
1.进程创建 先上代码: 1 #include"iostream" 2 #include<unistd.h> 3 int main() 4 { 5 using namespace std; 6 pid_t pid; 7 cout<<"parent have!"<<endl; 8 pid = fork();//执行fork的时候到底发生了什么? 9 if(pid == -1)//错误创建 10 { 11 perror("fork error"); 12 _exit(1); 13 } 14 else if(pid == 0)//子进程 15 { 16 17 cout<<"i am child,pid = "<<getpid()<<" my parent is:"<<getppid()<<endl; 18 } 19 else//父进程 20 { 21 // sleep(1); 22 cout<<"i am parent,pid = "<<getpid()<<" my parent is:"<<getppid()<<endl; 23 } 24 cout<<"both have!"<<endl; 25 return 0; 26 } 运行结果: 程序及结果分析: 2.创建多个子进程 1 #include"iostream" 2 #include<unistd.h> 3 int main() 4

android studio open debug mode when app is running

妖精的绣舞 提交于 2019-11-29 02:57:19
How can open debug mode when application is running on android studio., My application is appearing on - Android Device Monitor- Devices tab . When i clicked application line on this screen ,debug icon is not active How can i pass to debug mode after running my application? ingh.am In Android Studio (I'm currently using I/O Preview 0.2.10) simply click on the icon in the toolbar that looks like a phone with a bug over it - the hover text says: Attach debugger to Android process. It's the third icon along: A list will then appear showing your processes that you can debug. Choose one and select

How to check whether specified PID is currently running without invoking ps from PHP?

好久不见. 提交于 2019-11-28 22:32:09
We would like to check if a specified process is currently running via PHP. We would like to simply supply a PID and see if it is currently executing or not. Does PHP have an internal function that would give us this information or do we have to parse it out of "ps" output? If you are on Linux, try this : if (file_exists( "/proc/$pid" )){ //process with a pid = $pid is running } posix_getpgid($pid); will return false when a process is not running Steel Brain If you want to have a function for it then: $running = posix_kill($pid,0); Send the signal sig to the process with the process identifier

jmap -histo pid 输出的[C [B [I [S methodKlass constantPoolKlass含义

余生长醉 提交于 2019-11-28 22:04:00
JMAP 输出 [hadoop@DEV logs]$ jmap -histo 24527 | head -30 num #instances #bytes class name ---------------------------------------------- 1: 31939 98883072 [C 2: 8594 9461992 [B 3: 30326 4256232 <constMethodKlass> 4: 30326 3892592 <methodKlass> 5: 2719 3226344 <constantPoolKlass> 6: 2450 1948704 <constantPoolCacheKlass> 7: 2719 1869200 <instanceKlassKlass> 8: 27599 662376 java.lang.String 9: 836 442968 <methodDataKlass> 10: 8215 394320 org.apache.tomcat.util.buf.ByteChunk 11: 3012 366720 java.lang.Class 12: 11257 360224 java.util.HashMap$Entry 13: 3417 273360 java.lang.reflect.Method 14: 6763

golang 管理 pidfile

筅森魡賤 提交于 2019-11-28 21:58:08
Pidfile 存储了进程的进程 id。一般情况下 pidfile 有以下几个作用: 其他进程可以读取 pidfile 获取运行进程的 pid(当然也可以通过其他命令 动态获取) 在启动进程前先检查 pidfile,防止启动多个后台进程(特别像 agent 之类的) 下面是 docker 中管理 pidfile 的方法: package main import ( "fmt" "io/ioutil" "os" "path/filepath" "strings" log "github.com/sirupsen/logrus" ) func main() { _, err := NewPIDFile("pid.file") if err != nil { log.Errorf("error to create the pid file failed:%s", err.Error()) } } // PIDFile stored the process id type PIDFile struct { path string } // just suit for linux func processExists(pid string) bool { if _, err := os.Stat(filepath.Join("/proc", pid)); err == nil {

Linux pstree

微笑、不失礼 提交于 2019-11-28 20:11:40
常用参数 格式:pstree 以树状图显示进程,只显示进程的名字,且相同进程合并显示。 格式:pstree -p 以树状图显示进程,还显示进程PID。 格式:pstree <pid> 格式:pstree -p <pid> 以树状图显示进程PID为<pid>的进程以及子孙进程,如果有-p参数则同时显示每个进程的PID。 格式:pstree -a 以树状图显示进程,相同名称的进程不合并显示,并且会显示命令行参数,如果有-p参数则同时显示每个进程的PID。 因为pstree输出的信息可能比较多,所以最好与more/less配合使用。 来源: https://www.cnblogs.com/allenhaozi/p/11425858.html

How to restart Celery gracefully without delaying tasks

早过忘川 提交于 2019-11-28 20:05:14
问题 We use Celery with our Django webapp to manage offline tasks; some of these tasks can run up to 120 seconds. Whenever we make any code modifications, we need to restart Celery to have it reload the new Python code. Our current solution is to send a SIGTERM to the main Celery process ( kill -s 15 `cat /var/run/celeryd.pid` ), then to wait for it to die and restart it ( python manage.py celeryd --pidfile=/var/run/celeryd.pid [...] ). Because of the long-running tasks, this usually means the