seb-m / pyinotify

Monitoring filesystems events with inotify on Linux.
http://github.com/seb-m/pyinotify/wiki
MIT License
2.29k stars 379 forks source link

Pyinotify creates Zombie (defunct) processes #195

Open TheDevarshiShah opened 3 years ago

TheDevarshiShah commented 3 years ago

We are using latest Pyinotify (0.9.6) on a K8S cluster as a monitor. We are seeing Pyinotify creating 1 to 4 Zombie (defunct) processes. We couldn't find any fix or workaround. We have tried workaround mentioned in this issue both in Python 2 and 3 but it's not working. We also tried with different sleep seconds, still it's not working. See logs:

$ python2 --version
Python 2.7.5
$
$
$
$
$ ps -efl | egrep 'defunct|pyinotify'
0 S root  46030 24027  0    80   0 - 28203 pipe_w 15:07 pts/12   00:00:00 grep -E --color=auto defunct|pyinotify
$
$
$
$
$ python2 /usr/lib/python2.7/site-packages/pyinotify.py -e IN_MODIFY -f /tmp/pyinotify/text.txt -c 'sleep 1' & sleep 2 ; echo hello >temp.log
[1] 48953
$
$
$
$
$ ps -efl | egrep 'defunct|pyinotify'
0 S root  48953 24027  1    80   0 - 51855 poll_s 15:08 pts/12   00:00:00 python2 /usr/lib/python2.7/site-packages/pyinotify.py -e IN_MODIFY -f /tmp/pyinotify/text.txt -c sleep 1
0 Z root  48964 48953  0    80   0 -     0 do_exi 15:08 pts/12   00:00:00 [sleep] <defunct>
0 S root  51118 24027  0    80   0 - 28204 pipe_w 15:08 pts/12   00:00:00 grep -E --color=auto defunct|pyinotify
$
$
$
$
$ python2 /usr/lib/python2.7/site-packages/pyinotify.py --version
0.9.4
TheDevarshiShah commented 3 years ago

May we know some workaround to get rid of these zombie processes if possible?