checking for segfaults in execute_cmd, using always log file and and generalizing usage of execute_cmd