Questions tagged [pid]

Use this tag for questions about Process ID. For questions about PID-controllers, use [pid-controller] instead.

In computing, the process identifier (normally referred to as the process ID or just PID) is a number used by most operating system kernels (such as that of UNIX, Mac OS X or Microsoft Windows) to (temporarily) uniquely identify a process. This number may be used as a parameter in various function calls allowing processes to be manipulated, such as adjusting the process's priority or killing it altogether.

If your question is about Proportional Integral Derivative control, please use instead.

1697 questions
79
votes
4 answers

Maximum PID in Linux

I am porting an application from Tru64 to Linux and it uses PID_MAX defined in limits.h. Linux doesn't have that define. How do I find PID_MAX in c without reading /proc/sys/kernel/pid_max by hand? Is there a library?
Alexander Stolz
  • 7,454
  • 12
  • 57
  • 64
79
votes
4 answers

Must my pidfile be located in /var/run?

I'm asking in both contexts: technically and stylistically. Can my application/daemon keep a pidfile in /opt/my_app/run/? Is it very bad to do so? My need is this: my daemon runs under a specific user, and the implementor must mkdir a new…
gmoore
  • 5,506
  • 5
  • 29
  • 36
77
votes
5 answers

Can someone explain the structure of a Pid (Process Identifier) in Erlang?

Can someone explain the structure of a Pid in Erlang? Pids looks like this: , e.g. <0.30.0> , but I would like to know what is the meaning of these three "bits": A, B and C. A seems to be always 0 on a local node, but this value changes when…
jideel
  • 482
  • 2
  • 8
  • 14
73
votes
4 answers

How to get pid given the process name

Hi I have searched various forums and here as well, I could find some answers for Linux and Mac but not able to find solution for Unix and specially Korn Shell. How to get process name (command name) from process id (pid) Below reference I found…
gahlot.jaggs
  • 1,083
  • 3
  • 11
  • 21
72
votes
4 answers

Difference between PID and TID

What is the difference between PID and TID? The standard answer would be that PID is for processes while TID is for threads. However, I have seen that some commands use them interchangeably. For example, htop has a column for PIDs, in which PIDs for…
apoorv020
  • 5,420
  • 11
  • 40
  • 63
72
votes
14 answers

How to get the PID of a process that is piped to another process in Bash?

I am trying to implement a simple log server in Bash. It should take a file as a parameter and serve it on a port with netcat. ( tail -f $1 & ) | nc -l -p 9977 But the problem is that when the netcat terminates, tail is left behind running.…
Ertuğ Karamatlı
  • 898
  • 1
  • 6
  • 7
70
votes
9 answers

How to get the PID of a process by giving the process name in Mac OS X ?

I am writing a script to monitor the CPU and MEM of any given process. For that i need to send in the name of the process to be monitored as a commandline argument. For example. ./monitorscript I need to get the pid of the process in the…
Pradep
  • 1,874
  • 5
  • 21
  • 31
68
votes
12 answers

How do I kill a backgrounded/detached ssh session?

I am using the program synergy together with an ssh tunnel It works, i just have to open an console an type these two commands: ssh -f -N -L localhost:12345:otherHost:12345 otherUser@OtherHost synergyc localhost because im lazy i made an…
Skaarj
  • 827
  • 1
  • 6
  • 7
67
votes
6 answers

How to get PID of process by specifying process name and store it in a variable to use further?

By using "ucbps" command i am able to get all PIDs $ ucbps Userid PID CPU % Mem % FD Used Server Port ========================================================================= 512 5783 2.50 16.30 …
Nidhi
  • 829
  • 3
  • 8
  • 18
58
votes
10 answers

How to get PID by process name?

Is there any way I can get the PID by process name in Python? PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 3110 meysam 20 0 971m…
B Faley
  • 17,120
  • 43
  • 133
  • 223
57
votes
20 answers

ERROR! MySQL manager or server PID file could not be found! QNAP

I am having an issue where MySQL isn't starting on my QNAP NAS. I found this first by not being able to log in through phpMyAdmin - was getting error: #2002 Cannot log in to the MySQL server I then went to attempt to start mysql, as I guess this…
adprocas
  • 1,863
  • 1
  • 14
  • 31
55
votes
2 answers

How to get pid of android application without using adb shell?

How can I get an android application pid without using adb shell? Is there any API to get pid. any help will be appreciated
RanjitRock
  • 1,421
  • 5
  • 20
  • 36
55
votes
2 answers

What is the correct printf specifier for printing pid_t

I'm currently using a explicit cast to long and using %ld for printing pid_t, is there a specifier such as %z for size_t for pid_t? If not what the best way of printing pid_t?
Bilal Syed Hussain
  • 8,664
  • 11
  • 38
  • 44
54
votes
6 answers

Why does getpid() return pid_t instead of int?

What's the logic behind calls like getpid() returning a value of type pid_t instead of an unsigned int? Or int? How does this help? I'm guessing this has to do with portability? Guaranteeing that pid_t is the same size across different platforms…
ntl0ve
  • 1,896
  • 3
  • 19
  • 25
53
votes
6 answers

Check if process exists given its pid

Given the pid of a Linux process, I want to check, from a C program, if the process is still running.
Simone
  • 2,261
  • 2
  • 19
  • 27