Kevent, python y FreeBSD
Por Luis Peralta
Para la posteridad:
#!/usr/bin/python26
# kevent proc demo - luis peralta
# https://www.ziritione.org
#
# tested on python 2.6 % freebsd 7.2
import sys
import select
if __name__ == '__main__':
print sys.argv
kq = select.kqueue()
ke = select.kevent(int(sys.argv[1]),
select.KQ_FILTER_PROC,
select.KQ_EV_ADD|select.KQ_EV_ADD,
select.KQ_NOTE_FORK|select.KQ_NOTE_EXEC|select.KQ_NOTE_TRACK, select.KQ_NOTE_EXIT)
events = kq.control([ke], 0, 0)
while True:
events = kq.control([], 1, 0)
if len(events) > 0:
for event in events:
if event.fflags & select.KQ_NOTE_FORK:
print event.ident, "forked"
if event.fflags & select.KQ_NOTE_EXEC:
print event.ident, "called exec"
if event.fflags & select.KQ_NOTE_EXIT:
print event.ident, "exited"
if event.fflags & select.KQ_NOTE_CHILD:
print event.ident, "is child, parent ", event.data
Se puede probar así: python2.6 kevent-test.py $$ &