agnosticbin: Integrate mainloop instead of using a thread

Change-Id: I8cf225490626acbbf0b8cb0ccd967ba72aa9fcfb