Check return value of system call
Fix compilation issues for gcc 4.7