moved function from forkexit.c to misc.c