call system() function in a safely manner