reset context before makecontext call, check

check return value of swapcontext
replace 1 with EXIT_FAILURE in all err calls