Skip to main content
Typo, formatting.
Source Link
Stephen Kitt
  • 483.3k
  • 60
  • 1.2k
  • 1.4k

For Linux

What is the maximum value of the Process ID?

 $ cat /proc/sys/kernel/pid_max 4194304 $ sysctl kernel.pid_max kernel.pid_max = 4194304 

On a 32 bits-bit system, the results would be 3276832768.

If you are referring to the maximum value that can be achieved

According to the definitions in the Kernel: https://elixir.bootlin.com/linux/latest/source/include/linux/threads.h#L34

/* * This controls the default maximum pid allocated to a process */ #define PID_MAX_DEFAULT (CONFIG_BASE_SMALL ? 0x1000 : 0x8000) /* * A maximum of 4 million PIDs should be enough for a while. * [NOTE: PID/TIDs are limited to 2^30 ~= 1 billion, see FUTEX_TID_MASK.] */ #define PID_MAX_LIMIT (CONFIG_BASE_SMALL ? PAGE_SIZE * 8 : \ (sizeof(long) > 4 ? 4 * 1024 * 1024 : PID_MAX_DEFAULT)) 

You can check for the CONFIG_BASE_SMALL in

cat /boot/config-`uname -r`| grep -i config_base_small 

In my RHEL system, the calculation limited this to 2^22 = 4 * 1024 * 1024 ~ 4 Million

Test performed

>>> echo 4200000 > /proc/sys/kernel/pid_max; echo $? bash: echo: write error: Invalid argument 1 >>> echo 4194304 > /proc/sys/kernel/pid_max; echo $? 0 >>> echo 4194305 > /proc/sys/kernel/pid_max; echo $? bash: echo: write error: Invalid argument 1 

Also, is it possible to change a Process ID?

You cannot change the PID of the current process.
For changing the limit though, you can follow below.

## Using PROC interface. ## Changes Temporarily and immediate. It reverts to the default value after reboot echo "VALUE" > /proc/sys/kernel/pid_max ## Using sysctl interface; It is temporary and immediate too. sysctl -w kernel.pid_max=VALUE 

To persist this value, add the parameter to the either the file /etc/sysctl.conf or some file in /etc/sysctl.d/. To reload it:

sysctl -p [File from which the conf needs to be loaded if present] 

Reference:

For Linux

What is the maximum value of the Process ID?

 $ cat /proc/sys/kernel/pid_max 4194304 $ sysctl kernel.pid_max kernel.pid_max = 4194304 

On a 32 bits system, the results would be 32768.

If you are referring to the maximum value that can be achieved

According to the definitions in the Kernel: https://elixir.bootlin.com/linux/latest/source/include/linux/threads.h#L34

/* * This controls the default maximum pid allocated to a process */ #define PID_MAX_DEFAULT (CONFIG_BASE_SMALL ? 0x1000 : 0x8000) /* * A maximum of 4 million PIDs should be enough for a while. * [NOTE: PID/TIDs are limited to 2^30 ~= 1 billion, see FUTEX_TID_MASK.] */ #define PID_MAX_LIMIT (CONFIG_BASE_SMALL ? PAGE_SIZE * 8 : \ (sizeof(long) > 4 ? 4 * 1024 * 1024 : PID_MAX_DEFAULT)) 

You can check for the CONFIG_BASE_SMALL in

cat /boot/config-`uname -r`| grep -i config_base_small 

In my RHEL system, the calculation limited this to 2^22 = 4 * 1024 * 1024 ~ 4 Million

Test performed

>>> echo 4200000 > /proc/sys/kernel/pid_max; echo $? bash: echo: write error: Invalid argument 1 >>> echo 4194304 > /proc/sys/kernel/pid_max; echo $? 0 >>> echo 4194305 > /proc/sys/kernel/pid_max; echo $? bash: echo: write error: Invalid argument 1 

Also, is it possible to change a Process ID?

You cannot change the PID of the current process.
For changing the limit though, you can follow below.

## Using PROC interface. ## Changes Temporarily and immediate. It reverts to the default value after reboot echo "VALUE" > /proc/sys/kernel/pid_max ## Using sysctl interface; It is temporary and immediate too. sysctl -w kernel.pid_max=VALUE 

To persist this value, add the parameter to the either the file /etc/sysctl.conf or some file in /etc/sysctl.d/. To reload it:

sysctl -p [File from which the conf needs to be loaded if present] 

Reference:

For Linux

What is the maximum value of the Process ID?

 $ cat /proc/sys/kernel/pid_max 4194304 $ sysctl kernel.pid_max kernel.pid_max = 4194304 

On a 32-bit system, the results would be 32768.

If you are referring to the maximum value that can be achieved

According to the definitions in the Kernel: https://elixir.bootlin.com/linux/latest/source/include/linux/threads.h#L34

/* * This controls the default maximum pid allocated to a process */ #define PID_MAX_DEFAULT (CONFIG_BASE_SMALL ? 0x1000 : 0x8000) /* * A maximum of 4 million PIDs should be enough for a while. * [NOTE: PID/TIDs are limited to 2^30 ~= 1 billion, see FUTEX_TID_MASK.] */ #define PID_MAX_LIMIT (CONFIG_BASE_SMALL ? PAGE_SIZE * 8 : \ (sizeof(long) > 4 ? 4 * 1024 * 1024 : PID_MAX_DEFAULT)) 

You can check for the CONFIG_BASE_SMALL in

cat /boot/config-`uname -r`| grep -i config_base_small 

In my RHEL system, the calculation limited this to 2^22 = 4 * 1024 * 1024 ~ 4 Million

Test performed

>>> echo 4200000 > /proc/sys/kernel/pid_max; echo $? bash: echo: write error: Invalid argument 1 >>> echo 4194304 > /proc/sys/kernel/pid_max; echo $? 0 >>> echo 4194305 > /proc/sys/kernel/pid_max; echo $? bash: echo: write error: Invalid argument 1 

Also, is it possible to change a Process ID?

You cannot change the PID of the current process.
For changing the limit though, you can follow below.

## Using PROC interface. ## Changes Temporarily and immediate. It reverts to the default value after reboot echo "VALUE" > /proc/sys/kernel/pid_max ## Using sysctl interface; It is temporary and immediate too. sysctl -w kernel.pid_max=VALUE 

To persist this value, add the parameter to the either the file /etc/sysctl.conf or some file in /etc/sysctl.d/. To reload it:

sysctl -p [File from which the conf needs to be loaded if present] 

Reference:

For Linux

What is the maximum value of the Process ID?

 $ cat /proc/sys/kernel/pid_max 4194304 $ sysctl -akernel.pid_max  |kernel.pid_max grep= "pid_max"4194304 

On a 32 bits system, the results would be 32768.

If you are referring to the maximum value that can be achieved

According to the definitions in the Kernel: https://elixir.bootlin.com/linux/latest/source/include/linux/threads.h#L34

/* * This controls the default maximum pid allocated to a process */ #define PID_MAX_DEFAULT (CONFIG_BASE_SMALL ? 0x1000 : 0x8000) /* * A maximum of 4 million PIDs should be enough for a while. * [NOTE: PID/TIDs are limited to 2^30 ~= 1 billion, see FUTEX_TID_MASK.] */ #define PID_MAX_LIMIT (CONFIG_BASE_SMALL ? PAGE_SIZE * 8 : \ (sizeof(long) > 4 ? 4 * 1024 * 1024 : PID_MAX_DEFAULT)) 

You can check for the CONFIG_BASE_SMALL in

cat /boot/config-`uname -r`| grep -i config_base_small 

In my RHEL system, the calculation limited this to 2^22 = 4 * 1024 * 1024 ~ 4 Million

Test performed

>>> echo 4200000 > /proc/sys/kernel/pid_max; echo $? bash: echo: write error: Invalid argument 1 >>> echo 4194304 > /proc/sys/kernel/pid_max; echo $? 0 >>> echo 4194305 > /proc/sys/kernel/pid_max; echo $? bash: echo: write error: Invalid argument 1 

Also, is it possible to change a Process ID?

You cannot change the PID of the current process.
For changing the limit though, you can follow below.

## Using PROC interface. ## Changes Temporarily and immediate. It reverts to the default value after reboot echo "VALUE" > /proc/sys/kernel/pid_max ## Using sysctl interface; It is temporary and immediate too. sysctl -w kernel.pid_max=VALUE 

To persist this value, add the parameter to the either the file /etc/sysctl.conf or some file in /etc/sysctl.d/. To reload it:

sysctl -p [File from which the conf needs to be loaded if present] 

Reference:

For Linux

What is the maximum value of the Process ID?

 cat /proc/sys/kernel/pid_max sysctl -a | grep "pid_max" 

If you are referring to the maximum value that can be achieved

According to the definitions in the Kernel: https://elixir.bootlin.com/linux/latest/source/include/linux/threads.h#L34

/* * This controls the default maximum pid allocated to a process */ #define PID_MAX_DEFAULT (CONFIG_BASE_SMALL ? 0x1000 : 0x8000) /* * A maximum of 4 million PIDs should be enough for a while. * [NOTE: PID/TIDs are limited to 2^30 ~= 1 billion, see FUTEX_TID_MASK.] */ #define PID_MAX_LIMIT (CONFIG_BASE_SMALL ? PAGE_SIZE * 8 : \ (sizeof(long) > 4 ? 4 * 1024 * 1024 : PID_MAX_DEFAULT)) 

You can check for the CONFIG_BASE_SMALL in

cat /boot/config-`uname -r`| grep -i config_base_small 

In my RHEL system, the calculation limited this to 2^22 = 4 * 1024 * 1024 ~ 4 Million

Test performed

>>> echo 4200000 > /proc/sys/kernel/pid_max; echo $? bash: echo: write error: Invalid argument 1 >>> echo 4194304 > /proc/sys/kernel/pid_max; echo $? 0 >>> echo 4194305 > /proc/sys/kernel/pid_max; echo $? bash: echo: write error: Invalid argument 1 

Also, is it possible to change a Process ID?

You cannot change the PID of the current process.
For changing the limit though, you can follow below.

## Using PROC interface. ## Changes Temporarily and immediate. It reverts to the default value after reboot echo "VALUE" > /proc/sys/kernel/pid_max ## Using sysctl interface; It is temporary and immediate too. sysctl -w kernel.pid_max=VALUE 

To persist this value, add the parameter to the either the file /etc/sysctl.conf or some file in /etc/sysctl.d/. To reload it:

sysctl -p [File from which the conf needs to be loaded if present] 

Reference:

For Linux

What is the maximum value of the Process ID?

 $ cat /proc/sys/kernel/pid_max 4194304 $ sysctl kernel.pid_max  kernel.pid_max = 4194304 

On a 32 bits system, the results would be 32768.

If you are referring to the maximum value that can be achieved

According to the definitions in the Kernel: https://elixir.bootlin.com/linux/latest/source/include/linux/threads.h#L34

/* * This controls the default maximum pid allocated to a process */ #define PID_MAX_DEFAULT (CONFIG_BASE_SMALL ? 0x1000 : 0x8000) /* * A maximum of 4 million PIDs should be enough for a while. * [NOTE: PID/TIDs are limited to 2^30 ~= 1 billion, see FUTEX_TID_MASK.] */ #define PID_MAX_LIMIT (CONFIG_BASE_SMALL ? PAGE_SIZE * 8 : \ (sizeof(long) > 4 ? 4 * 1024 * 1024 : PID_MAX_DEFAULT)) 

You can check for the CONFIG_BASE_SMALL in

cat /boot/config-`uname -r`| grep -i config_base_small 

In my RHEL system, the calculation limited this to 2^22 = 4 * 1024 * 1024 ~ 4 Million

Test performed

>>> echo 4200000 > /proc/sys/kernel/pid_max; echo $? bash: echo: write error: Invalid argument 1 >>> echo 4194304 > /proc/sys/kernel/pid_max; echo $? 0 >>> echo 4194305 > /proc/sys/kernel/pid_max; echo $? bash: echo: write error: Invalid argument 1 

Also, is it possible to change a Process ID?

You cannot change the PID of the current process.
For changing the limit though, you can follow below.

## Using PROC interface. ## Changes Temporarily and immediate. It reverts to the default value after reboot echo "VALUE" > /proc/sys/kernel/pid_max ## Using sysctl interface; It is temporary and immediate too. sysctl -w kernel.pid_max=VALUE 

To persist this value, add the parameter to the either the file /etc/sysctl.conf or some file in /etc/sysctl.d/. To reload it:

sysctl -p [File from which the conf needs to be loaded if present] 

Reference:

Source Link

For Linux

What is the maximum value of the Process ID?

 cat /proc/sys/kernel/pid_max sysctl -a | grep "pid_max" 

If you are referring to the maximum value that can be achieved

According to the definitions in the Kernel: https://elixir.bootlin.com/linux/latest/source/include/linux/threads.h#L34

/* * This controls the default maximum pid allocated to a process */ #define PID_MAX_DEFAULT (CONFIG_BASE_SMALL ? 0x1000 : 0x8000) /* * A maximum of 4 million PIDs should be enough for a while. * [NOTE: PID/TIDs are limited to 2^30 ~= 1 billion, see FUTEX_TID_MASK.] */ #define PID_MAX_LIMIT (CONFIG_BASE_SMALL ? PAGE_SIZE * 8 : \ (sizeof(long) > 4 ? 4 * 1024 * 1024 : PID_MAX_DEFAULT)) 

You can check for the CONFIG_BASE_SMALL in

cat /boot/config-`uname -r`| grep -i config_base_small 

In my RHEL system, the calculation limited this to 2^22 = 4 * 1024 * 1024 ~ 4 Million

Test performed

>>> echo 4200000 > /proc/sys/kernel/pid_max; echo $? bash: echo: write error: Invalid argument 1 >>> echo 4194304 > /proc/sys/kernel/pid_max; echo $? 0 >>> echo 4194305 > /proc/sys/kernel/pid_max; echo $? bash: echo: write error: Invalid argument 1 

Also, is it possible to change a Process ID?

You cannot change the PID of the current process.
For changing the limit though, you can follow below.

## Using PROC interface. ## Changes Temporarily and immediate. It reverts to the default value after reboot echo "VALUE" > /proc/sys/kernel/pid_max ## Using sysctl interface; It is temporary and immediate too. sysctl -w kernel.pid_max=VALUE 

To persist this value, add the parameter to the either the file /etc/sysctl.conf or some file in /etc/sysctl.d/. To reload it:

sysctl -p [File from which the conf needs to be loaded if present] 

Reference: