Making 1 function call is far less expensive than a fork, exec of a shell in the child process, another fork, exec of uname in the child process, all so that the uname process can make the same function call.
With this approach, there is no doubt that the output goes to fop.
I moved the fflush(fop) call below the second print to fop, but I am 99% sure that it could be removed entirely with no ill effects. A newline at the end of a string usually triggers a flush anyway.
This change has multiple benefits:
I moved the
fflush(fop)
call below the second print to fop, but I am 99% sure that it could be removed entirely with no ill effects. A newline at the end of a string usually triggers a flush anyway.