done major refactoring and implement signal fd (not tested yet)