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
521
votes
9 answers

How to get process ID of background process?

I start a background process from my shell script, and I would like to kill this process when my script finishes. How to get the PID of this process from my shell script? As far as I can see variable $! contains the PID of the current script, not…
Volodymyr Bezuglyy
  • 16,295
  • 33
  • 103
  • 133
435
votes
37 answers

Port 80 is being used by SYSTEM (PID 4), what is that?

I am trying to use port 80 for my application server, but when I perform netstat -aon I get: TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4 When I look up the process in task manager, it shows PID 4 is SYSTEM, that's it. No extension... nothing. Just…
GiH
  • 14,006
  • 13
  • 43
  • 56
418
votes
22 answers

How can a Java program get its own process ID?

How do I get the id of my Java process? I know there are several platform-dependent hacks, but I would prefer a more generic solution.
Dmitry Shechtman
  • 6,548
  • 5
  • 26
  • 25
245
votes
11 answers

How to check if a process id (PID) exists

In a bash script, I want to do the following (in pseudo-code): if [ a process exists with $PID ]; then kill $PID fi What's the appropriate expression for the conditional statement?
Richard H
  • 38,037
  • 37
  • 111
  • 138
235
votes
4 answers

What is a .pid file and what does it contain?

I recently came across a file with the extension .pid and looked inside it but didn't find much. The documentation says: A Pid-File is a file containing the process identification number (pid) that is stored in a well-defined location of the…
ifixthat
  • 6,137
  • 5
  • 25
  • 42
211
votes
7 answers

How can a Linux/Unix Bash script get its own PID?

I have a script in Bash called Script.sh that needs to know its own PID. In other words, I need to get PID inside Script.sh. Any idea how to do this?
Debugger
  • 9,130
  • 17
  • 45
  • 53
191
votes
8 answers

Why is $$ returning the same id as the parent process?

I have problem with Bash, and I don't know why. Under shell, I enter: echo $$ ## print 2433 (echo $$) ## also print 2433 (./getpid) ## print 2602 Where getpid is a C program to get current pid, like: int main() { printf("%d",…
ruanhao
  • 4,663
  • 6
  • 28
  • 43
139
votes
15 answers

How to check if there exists a process with a given pid in Python?

Is there a way to check to see if a pid corresponds to a valid process? I'm getting a pid from a different source other than from os.getpid() and I need to check to see if a process with that pid doesn't exist on the machine. I need it to be…
Evan Fosmark
  • 98,895
  • 36
  • 105
  • 117
134
votes
14 answers

What is the best way to ensure only one instance of a Bash script is running?

What is the simplest/best way to ensure only one instance of a given script is running - assuming it's Bash on Linux? At the moment I'm doing: ps -C script.name.sh > /dev/null 2>&1 || ./script.name.sh but it has several issues: it puts the check…
user80168
120
votes
3 answers

If threads share the same PID, how can they be identified?

I have a query related to the implementation of threads in Linux. Linux does not have an explicit thread support. In userspace, we might use an thread library (like NPTL) for creating threads. Now if we use NPTL it supports 1:1 mapping. The kernel…
SPSN
  • 1,411
  • 2
  • 13
  • 14
115
votes
38 answers

Failed to Attach to Process ID Xcode

Anyone has experienced this problem? Yesterday I still can run my app in simulator but now I cannot run my app since Xcode prints this error in console: error: failed to attach to process ID I have tried to reinstall, do this post and…
Rendy
  • 5,572
  • 15
  • 52
  • 95
108
votes
8 answers

Determine the process pid listening on a certain port

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…
Cyclone
  • 14,839
  • 23
  • 82
  • 114
108
votes
4 answers

Postgres DB not starting on Mac OSX: ERROR says: connections on Unix domain socket

I ve installed Postgresql and then ran a bunch of rails apps on my local Mac OSX Mountain Lion and created databases etc. Today after a while when I launched pgAdminIII and tried to launch a database server I got this error: A quick google showed…
banditKing
  • 9,405
  • 28
  • 100
  • 157
88
votes
18 answers

How to get PID of process I've just started within java program?

I've started a process with following code ProcessBuilder pb = new ProcessBuilder("cmd", "/c", "path"); try { Process p = pb.start(); } catch (IOException ex) {} Now I need to know the process's pid that I've just started.
raf
  • 1,121
  • 3
  • 13
  • 14
81
votes
2 answers

Linux PID recycling

Is there any policy in Linux as to the recycling of used PIDs ? I mean, if a PId has been used, how much later will it be used again ?
Cygnus
  • 3,222
  • 9
  • 35
  • 65
1
2 3
99 100