It's not always possible to determine if the application is set-uid.
In some cases it's not.
Solaris/Illumos and OpenBSD have the only fail-safe method: the
issetugid(2) system call. FreeBSD and NetBSD have a system call with
the same name that unfortunately doesn't quite work correctly but which
will do. Recent Linux kernels supply ELF aux vector entries that
include the necessary information.