system() , , , - . , (), .
, fork() exec*(), , . :
void replace_system(const char *command)
{
pid_t child = fork();
if (child < 0) {
perror("fork:");
return;
}
if (child) {
while (waitpid(child, &status, options) <= 0);
return;
}
exec*(...);
perror("failed to start the child");
exit(-1);
}
exec *, , . , , . exec *, ( , ).
, - , . , ; stdout, , , . popen(), .