Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Closes leaked deleted and eventfd left by docker
#!/bin/bash
export PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin
docker_pid=$(cat /var/run/docker.pid)
gdb -p $docker_pid <<< "$( ls /proc/$docker_pid/fd -l --time-style=+'%s' | grep -E 'deleted' | awk '{ printf("p close(%s)\n", $7)}')" >/dev/null
#closing evenfds that do not have a corresponding memory.oom_control
eventfds="$(for eventfd in $(ls /proc/$docker_pid/fd -l --time-style=+'%s' | grep -E 'eventfd'| awk '{print $7}'); do
memory_pid=$((eventfd - 1))
if [ -f /proc/$docker_pid/fd/$memory_pid ] && ! ( ls -l /proc/$docker_pid/fd/$memory_pid | grep 'memory.oom_control' >/dev/null ) ; then
echo "p close($eventfd)"
fi
done)"
gdb -p $docker_pid <<< "$eventfds"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.