Re: system command returning unknown error.
Re: system command returning unknown error.
- Subject: Re: system command returning unknown error.
- From: Michael Smith <email@hidden>
- Date: Wed, 14 Jun 2006 18:45:03 -0700
On Jun 14, 2006, at 12:48 PM, "matt jaffa" <email@hidden> wrote:
Yes I am running as a root process.
On 6/14/06, John Francini <email@hidden> wrote:
/sbin/shutdown must be run by root. Running as a user with
Administrator privilege is not sufficient.
Is the parent process running as root or setuid to root?
John
On 14 Jun 2006, at 15:15, matt jaffa wrote:
Ok so I admit I read it wrong regarding the return status, always
got
0 for everything else I executed so I assumed 0 good and only -1 was
returned if bad.
soo I am getting 32256 by executing system("/sbin/shutdown -r
now");
Matt,
It's a very good thing that you are getting this error.
You should not be calling system(3), and most especially you should
not be calling it from a process running as root.
Please consult your copy of "Advanced Programming in the Unix
Environment" by W. Richard Stevens, and see his
straightforward examples on the correct usage of fork(2) and execv
(2), which will do what you want just fine.
Incidentally, unless you are shutting the system down in an
emergency, invoking shutdown(8) may not be the correct way to bring
the system down. It's definitely not polite to any currently-logged-
in console user.
= Mike
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden