pid

Is it possible for an app to have several PID at the same time?

两盒软妹~` 提交于 2021-02-11 10:17:21
问题 I have done some experiments and to my knowledge, an app can create several instances of ART (AndroidRunTime) that can execute code concurrently. Each of these instances are called by the same PID than the app. Each of these ART instances can create several threads and these threads have the app PID. But is it possible for an app to have several PID simultaneously? If it is the case could you provide an example? 来源: https://stackoverflow.com/questions/41898846/is-it-possible-for-an-app-to

Is it possible for an app to have several PID at the same time?

情到浓时终转凉″ 提交于 2021-02-11 10:17:05
问题 I have done some experiments and to my knowledge, an app can create several instances of ART (AndroidRunTime) that can execute code concurrently. Each of these instances are called by the same PID than the app. Each of these ART instances can create several threads and these threads have the app PID. But is it possible for an app to have several PID simultaneously? If it is the case could you provide an example? 来源: https://stackoverflow.com/questions/41898846/is-it-possible-for-an-app-to

How to make parent process wait for child processes to finish?

社会主义新天地 提交于 2021-02-10 18:20:37
问题 I have an assignment which gives me this code to transform into a code that makes the parent process wait for all children processes to finish. PS: the first code has 4 processes and needs to use waitpid to solve this. #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <unistd.h> int main(){ pid_t p = fork(); pid_t k = fork(); if(p>0){ printf("p=%d: PID = %d\n", p, getpid()); sleep(45); exit(0); } else if(p==0){ printf("p=%d: PID = %d\n", p, getpid()); exit(0); } else if(p

How to make parent process wait for child processes to finish?

左心房为你撑大大i 提交于 2021-02-10 18:19:43
问题 I have an assignment which gives me this code to transform into a code that makes the parent process wait for all children processes to finish. PS: the first code has 4 processes and needs to use waitpid to solve this. #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <unistd.h> int main(){ pid_t p = fork(); pid_t k = fork(); if(p>0){ printf("p=%d: PID = %d\n", p, getpid()); sleep(45); exit(0); } else if(p==0){ printf("p=%d: PID = %d\n", p, getpid()); exit(0); } else if(p

How to get the pid of a process that is listening on a certain port programmatically?

依然范特西╮ 提交于 2021-02-06 12:57:16
问题 I have to write a SNMP module which monitor a certain server application that I have written too. The problem is that I have to know if this application is running and I should be able to kill it whenever I can. I know the port where the application is listening (reading the application configuration file) and I can try to bind this port to a socket in order to know if it is (or isn't) being used by my application or another which is enough for my module. Here is the code: int get_server

How to get the pid of a process that is listening on a certain port programmatically?

筅森魡賤 提交于 2021-02-06 12:53:26
问题 I have to write a SNMP module which monitor a certain server application that I have written too. The problem is that I have to know if this application is running and I should be able to kill it whenever I can. I know the port where the application is listening (reading the application configuration file) and I can try to bind this port to a socket in order to know if it is (or isn't) being used by my application or another which is enough for my module. Here is the code: int get_server

In python is there a cross-platform way of determining what process is listening to a given port?

落爺英雄遲暮 提交于 2021-01-27 17:42:57
问题 In linux, I can use lsof -i as in the following function: def FindProcessUsingPort(portnum): import os fp = os.popen("lsof -i :%s" % portnum) lines = fp.readlines() fp.close() pid = None if len(lines) >= 2: pid = int(lines[1].split()[1]) return pid Is there a cross-platform way to figure this out? As a relevant reference, once I know the process id, the psutil library is very nice and lets me determine all sorts of useful process information for it in a cross-platform way. I just can't get