c - system function flaws -


we using c in linux. there possibility system() function can behave in unexpected manner, when handle signals?

we found sometimes, system() function blocks execution or throws sigsegv.

e.g:

system ( "/bin/mv b" ); 

are there known flaws in using system() explain this?

the system() function supposed well. behaviour pretty reliable long invoked correctly. has 2 modes of operation:

  1. check whether there command interpreter available - when argument null pointer.
  2. run command given, waiting command complete before returning.

so, system() statement blocks until shell runs command completes. on unix-like systems, command invoked effectively:

"sh", "-c", "...argument system...", null 

this means string passed interpreted shell. how long takes depends on command executed. can consider using shell notations run command in background if need to:

system("( /bin/mv b & )"); 

there few circumstances system() generate sigsegv. have pass invalid pointer, pointer somewhere invalid in program.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -