How to restart or shutdown the whole computer with a command inside a pthreads-process?

exec ("reboot"); ??
exec("shutdown now");??