title: How can my C/C++ application determine if the root user is executing the command?
body: <p>I am writing an application that requires root user privileges to execute. If executed by a non root user, it exits and terminates with a perror message such as:</p>
  <pre><code>    pthread_getschedparam: Operation not permitted
  </code></pre>
  <p>I would like to make the application more user friendly. As part of its early initialization I would like it to check if it is being executed by root or not. And if not root, it would present a message indicating that it can only be run by root, and then terminate.</p>