Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximum PID in Linux

Tags:

c

linux

pid

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?

like image 427
Alexander Stolz Avatar asked Jun 09 '11 14:06

Alexander Stolz


People also ask

How many digits is a PID?

All PIDs are nine digit numbers that begin with a 7.

What is the maximum number of process in Linux?

The maximum user processes (nproc) limit on Linux counts the number of threads within all processes that can exist for a given user. The default value of nproc is 1024 on some versions of Linux, which is generally an insufficient number of threads for all processes.

How is PID determined in Linux?

A PID is automatically assigned to each process when it is created. A process is nothing but running instance of a program and each process has a unique PID on a Unix-like system. The easiest way to find out if process is running is run ps aux command and grep process name.

What are PID in Linux?

Overview. As Linux users, we're familiar with process identifiers (PID). PID is the operating system's unique identifier for active programs that are running. A simple command to view the running processes shows that the init process is the owner of PID 1.


1 Answers

It's 32768 by default, you can read the value on your system in /proc/sys/kernel/pid_max.

And you can set the value higher on 64-bit systems (up to 222 = 4,194,304) with:

echo 4194304 > /proc/sys/kernel/pid_max 

Read more here:

http://www.cs.wisc.edu/condor/condorg/linux_scalability.html (via archive.org)

like image 199
Exos Avatar answered Oct 31 '22 18:10

Exos