Fixed a bug in daemon restart function.