Shell process execution almost working but getting seg fault after second attempt