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:
What you really want to check for is if you have the right capability set (CAP_SYS_NICE I think is the capability you need) see man pages capabilities (7) and capget (2) this way it won't error out if you have the ability to do what you want, but you aren't root.