0

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

WilliamKF
  • 41,123
  • 68
  • 193
  • 295

2 Answers2

1

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.

Void - Othman
  • 3,441
  • 18
  • 18
0

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

larsmoa
  • 12,604
  • 8
  • 62
  • 85