Process IDs (PIDs) are unique numerical identifiers assigned by Unix-like operating systems to running processes. In both Linux and Solaris, these values follow specific range limitations dictated by kernel implementations and system configurations.
Modern Linux systems (kernel 2.6+) implement the following PID constraints:
// Check current PID limits on Linux
cat /proc/sys/kernel/pid_max
// Typical output: 32768
Key specifications:
- Minimum PID: 1 (init/systemd process)
- Maximum default PID: 32768 (configurable up to 2^22 ~ 4,194,304 in 64-bit systems)
- Reserved PIDs: 0 (swapper) and negative values for special cases
Solaris systems handle PIDs differently:
# Check maximum PID on Solaris
sysdef | grep PID_MAX
# Typical output: PID_MAX 30000
Solaris specifics:
- Minimum PID: 0 (sched process)
- Default maximum PID: 30000 (adjustable via /etc/system)
- Special case: PID 0 reserved for kernel scheduler
When programming for cross-platform compatibility:
// C code example for PID range checking
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
void check_pid_range(pid_t pid) {
#if defined(__linux__)
if (pid < 1 || pid > 32768) {
fprintf(stderr, "Invalid Linux PID range\n");
}
#elif defined(__sun)
if (pid < 0 || pid > 30000) {
fprintf(stderr, "Invalid Solaris PID range\n");
}
#endif
}
To modify PID ranges:
Linux:
# Temporary change
echo 65536 > /proc/sys/kernel/pid_max
# Permanent change (add to /etc/sysctl.conf)
kernel.pid_max = 65536
Solaris:
# Edit /etc/system
set pid_max=60000
Signs of PID exhaustion include:
- Failure to launch new processes
- "Resource temporarily unavailable" errors
- High system load with few actual processes
# Check PID usage
ps -eLf | wc -l
# Compare with system limits
cat /proc/sys/kernel/pid_max
On Unix-like systems including Linux and Solaris, each process is assigned a unique Process ID (PID) when created. The PID range is system-dependent and affects process management operations.
Modern Linux systems (kernel 2.6+) typically use these PID limits:
Minimum PID: 1 (init process) Maximum PID: 32768 (configurable via /proc/sys/kernel/pid_max)
You can check the current maximum PID value with:
cat /proc/sys/kernel/pid_max
To temporarily change the maximum PID value (as root):
echo 65536 > /proc/sys/kernel/pid_max
Solaris systems have different PID allocation behavior:
Minimum PID: 0 (sched process) Maximum PID: 30000 (default, configurable via maxpid in /etc/system)
To check the current maximum PID on Solaris:
sysdef | grep MAXPID
To permanently change the maximum PID, add this to /etc/system:
set maxpid=60000
When writing system tools that work with PIDs, consider these constraints:
// C code example to check PID validity #include#include int is_valid_pid(pid_t pid) { #ifdef __linux__ return (pid > 0 && pid <= 32768); #elif __sun return (pid >= 0 && pid <= 30000); #endif }
When the maximum PID is reached, both systems will wrap around to find available PIDs. Linux typically starts searching from 300 again (leaving lower PIDs for system processes), while Solaris may start from 1.
When forking processes programmatically, always check for failure cases:
pid_t pid = fork(); if (pid == -1) { // Handle fork failure (possibly PID exhaustion) perror("fork failed"); exit(EXIT_FAILURE); }