Good way to send result of 'uname -a' to a stream?

601 Views Asked by At

What is a good way to call 'uname -a' from a C++ program and send the results to a stream?

I looked at system() and exec(), but they do not seem to give access to the stdout of the call.

Thanks.

-William

2

There are 2 best solutions below

0
On BEST ANSWER

Why not just retrieve the strings directly from the struct utsname returned from the uname(2) system call found on most Unix/Unix-like platforms?

No need to fork a "uname -a" process.

0
On

Another option (if you are using Qt) is to use QProcess.