How to Fix Linux Kill Process — Resource Temporarily Unavailable
In this tutorial, you'll learn about How to Fix Linux Kill Process. We cover key concepts, practical examples, and best practices.
You run kill <PID> and get Resource temporarily unavailable — the process is in an uninterruptible sleep state (D state) or the system has reached its process limit.
The Problem
kill: (1234): Resource temporarily unavailable
Or:
kill: cannot kill process: Resource temporarily unavailable
Step-by-Step Fix
Step 1: Check the process state
ps aux | grep 1234
Look at the STAT column:
D— uninterruptible sleep (cannot be killed)Z— zombie (already dead, parent must reap)T— stoppedS— sleepingR— running
Step 2: Try SIGKILL for normal processes
# WRONG — default SIGTERM may not work
kill 1234
# RIGHT — use SIGKILL
kill -9 1234
Or:
kill -KILL 1234
Step 3: Handle zombie processes
# Zombie processes cannot be killed
ps aux | grep Z
Kill the parent process to reap the zombie:
kill -9 <parent-pid>
Step 4: Handle D-state (uninterruptible sleep) processes
D-state processes are waiting on I/O. If the underlying storage is stuck, the process cannot be killed. Options:
- Fix the storage issue (mount, NFS, disk)
- Reboot the system
- Wait for I/O timeout
Check what the process is waiting on:
cat /proc/1234/status | grep -E "State|Pid"
Step 5: Check system process limits
ulimit -u
If you hit the max user processes limit:
# Check current count
ps -U $USER | wc -l
# If near limit, increase
ulimit -u 65535
Make permanent in /etc/security/limits.conf:
user soft nproc 65535
user hard nproc 65535
Step 6: Reboot if necessary
sudo reboot
Prevention Tips
- Use
kill -15(SIGTERM) first, thenkill -9(SIGKILL) - Avoid NFS mounts with hard options (use
softorintr) - Monitor system limits with
ulimit -a - Set appropriate process limits in production
- Use
pkillorkillallfor pattern-based killing
Common Mistakes with process kill
- Misunderstanding that
Stringis[Char]with poor performance for large text operations - Using
foldlinstead offoldl'causing stack overflow on large lists - Forgetting
deriving (Show, Eq)on custom data types needed for debugging
These mistakes appear frequently in real-world LINUX code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro