pid

How to find Bundle Identifier from known PID?

时间秒杀一切 提交于 2019-12-04 08:55:43
I have the pid (process identifier) of an arbitrary running process. How can I find the bundle identifier (if any) of the associated application? Here's a way that works in 10.2 and later: First call GetProcessForPID to turn the pid into a ProcessSerialNumber . Then call ProcessInformationCopyDictionary to get the bundle ID. (Added: these functions are deprecated in OS 10.9. I don't know if they still exist in the 10.10 SDK.) I've found an answer which works on 10.6 only: [[NSRunningApplication runningApplicationWithProcessIdentifier:pid] bundleIdentifier] 来源: https://stackoverflow.com

setpgid

和自甴很熟 提交于 2019-12-04 08:25:05
setpgid将参数pid指定进程所属的组识别码设为参数pgid指定的组识别码。如果参数pid 为0,则会用来设置目前进程的组识别码,如果参数pgid为0,则由pid指定的进程ID将用作进程组ID。一个进程只能为它自己或它的子进程设置进程组ID #include<unistd.h> int setpgid(pid_t pid,pid_t pgid); 函数作用:将pid进程的进程组ID设置成pgid,创建一个新进程组或加入一个已存在的进程组 函数性质: 性质1:一个进程只能为自己或子进程设置进程组ID,不能设置其父进程的进程组ID。 性质2:if(pid == pgid), 由pid指定的进程变成进程组长;即进程pid的进程组ID pgid=pid. 性质3:if(pid==0),将当前进程的pid作为进程组ID. 性质4:if(pgid==0),将pid作为进程组ID. 函数使用说明:一般自己调用该函数时,最好是明确指定pid和pgid,方便阅读代码流程;若想特意为之,就要会用性质 来源: https://www.cnblogs.com/hshy/p/11848230.html

Determine the process pid listening on a certain port

余生颓废 提交于 2019-12-04 07:29:31
问题 As the title says, I'm running multiple game servers, and every of them has the same name but different PID and the port number. I would like to match the PID of the server which is listening on certain port, and then I would like to kill this process. I need that in order to complete my bash script. Is that even possible? Because it didn't find yet any solutions on the web. 回答1: The -p flag of netstat gives you PID of the process: netstat -l -p Edit: The command that is needed to get PIDs of

OSX - How can I see the TID of all threads from my process?

若如初见. 提交于 2019-12-04 06:44:46
On Linux ps -eLf | grep my-process-name gives a list of the threads within my process along with the TID of each thread. On OSX ps -M pid gives me the list of the threads but does not show the TID of each thread. How can I see thread TIDs under a single process from the command line? You can't see the TIDs with the ps on Mac OS as you can experience while listing all the possible column options with ps L . Anyway, if you dont mind exploring the threads as a root, you can use dtruss , which is primarily for processing syscall details, but it will at least show you the TIDs in the PID/ LWPID

PHP使用递归按层级查找数据

给你一囗甜甜゛ 提交于 2019-12-04 03:48:52
今天主要介绍一下使用递归来按层级查找数据。 原理挺简单的,主要是通过父级id一级一级的循环查找子级,使用PHP循环代码也很容易实现,不过如果层级越多,PHP重复代码也越多,这时可以使用递归来实现这功能。 1、首先查出要使用的数据组成一个数组(避免递归里查询数据库,之后根据这个数组组成自己需要的数据就可以了) 比如得到如下数据: $data = [ ['id' => '1', 'pid' => '0', 'dsp' => '1'], ['id' => '2', 'pid' => '0', 'dsp' => '2'], ['id' => '3', 'pid' => '0', 'dsp' => '3'], ['id' => '4', 'pid' => '1', 'dsp' => '1-4'], ['id' => '5', 'pid' => '4', 'dsp' => '1-4-5'], ['id' => '6', 'pid' => '5', 'dsp' => '1-4-5-6'], ['id' => '7', 'pid' => '3', 'dsp' => '3-7'], ['id' => '8', 'pid' => '2', 'dsp' => '2-8'], ['id' => '9', 'pid' => '1', 'dsp' => '1-9'], ['id' => '10', 'pid'

Wait until a certain process (knowing the “pid”) end

偶尔善良 提交于 2019-12-04 02:47:18
问题 I have this: def get_process(): pids = [] process = None for i in os.listdir('/proc'): if i.isdigit(): pids.append(i) for pid in pids: proc = open(os.path.join('/proc', pid, 'cmdline'), 'r').readline() if proc == "Something": process = pid return process def is_running(pid): return os.path.exists("/proc/%s" % str(pid)) Then i do this: process = get_process() if process == None: #do something else: #Wait until the process end while is_running(process): pass I think this is not the best way to

Java进程cpu占用过高快速定位

穿精又带淫゛_ 提交于 2019-12-03 23:57:02
1 找到高消耗cpu的进程,使用ProcessExplorer工具查看进程中的哪个线程cpu使用率过高 2 在ProcessExplorer中选中要查看的进程,右键选择properties,查看哪个线程频繁使用cpu 3 利用jstack命令输出运行栈信息 在cmd中输入Jstack -l pid >>123.txt pid是进程即应用的pid,123.txt是要输出的文件名字 4 将第2步查看的线程的十进制pid,转换成16进制,在123.txt中搜索,就可以看到这个线程中哪个部分在高消耗cpu 来源: CSDN 作者: liyunfei456 链接: https://blog.csdn.net/liyunfei456/article/details/100859398

Get the logon session of a user in C++

谁说我不能喝 提交于 2019-12-03 21:51:17
I want to get a handle on the current logon session of processes whose parent is explorer.exe. If we run a process as administrator or a service it won't have a logon session. The reason I want to get the logon session is that I have a program (.exe) which I want to restrict opening when a user tries to open it via (right click on the .exe--> run as administrator) and when a user opens it via administrator we don't have a logon session associated with it whereas when a user opens it by double clicking on it, it has a logon session associated with it. I searched quite some places, but I just

Is it possible to get the launch time of PID?

╄→尐↘猪︶ㄣ 提交于 2019-12-03 20:54:21
I have a code that is floating around here for a while (the code is working for me): - (NSArray *) runningProcesses { //CTL_KERN,KERN_PROC,KERN_PROC_ALL int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL ,0}; size_t miblen = 4; size_t size; int st = sysctl(mib, miblen, NULL, &size, NULL, 0); struct kinfo_proc * process = NULL; struct kinfo_proc * newprocess = NULL; do { size += size / 10; newprocess = realloc(process, size); if (!newprocess) { if (process) { free(process); process = NULL; } return nil; } process = newprocess; st = sysctl(mib, miblen, process, &size, NULL, 0); } while (st == -1 &

How to use same terminal window after using “rails server” command?

你说的曾经没有我的故事 提交于 2019-12-03 18:18:14
问题 Okay here's my problem. I type in "rails s" and then my terminal won't let me type in any commands. So I have to start a new terminal window, which is pretty annoying. On the other hand I can type in "rails s -d" which detaches, and then it's a pain to stop the server when I need to. (Instead of using control+c, I have to find the PID and use kill -9 PID) I'm not a professional, so if anyone has any advice it would be much appreciated, thank you! 回答1: I don't believe there is a way to do the