Re: system command returning unknown error.
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=uRlIPJ3G5TMnzhOsDQAzWVwDhsTHf180/niOYa690DtNVjm0grLMKh4Pm4KzOMCsaI4DMKy2HqNyME9i308ggJOe9mHttN4jq/+L+8KPFBP2FMgtQX/7kKy75QcP3CPB2EmkM7mx1cQ1/HVG6wNyhRjsfsxehqAHp9JiFukmktk= I tried to switch to using the reboot(int howto) command instead of system("/sbin/shutdown -r now") and I am getting back errno = 1, operation not permitted. I am running as root since I set setuid(0) before running the command. And the permissions on my commandline app allow me to setuid(0) as bad as some might think, this is the only way this tool will work for our product. But operation not permitted hasn't anything to do with priviliges I think. Cause I can go to the terminal and do a sudo /sbin/reboot just fine. Yes I am running as a root process. On 6/14/06, John Francini <francini@mac.com> 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");
On 6/14/06, John Francini <francini@mac.com > wrote:
Rather than having people say "Yes, I did, No, I didn't", let's cut the Gordian knot.
The man page on 10.4.6 reads as follows:
SYSTEM(3) BSD Library Functions Manual SYSTEM(3)
NAME system -- pass a command to the shell
LIBRARY Standard C Library (libc, -lc)
SYNOPSIS #include <stdlib.h>
int system(const char *string);
DESCRIPTION The system() function hands the argument string to the command inter- preter sh(1). The calling process waits for the shell to finish execut- ing the command, ignoring SIGINT and SIGQUIT, and blocking SIGCHLD.
If string is a NULL pointer, system() will return non-zero if the command interpreter sh(1) is available, and zero if it is not.
The system() function returns the exit status of the shell as returned by waitpid(2), or -1 if an error occurred when invoking fork(2) or waitpid(2). A return value of 127 means the execution of the shell failed.
SEE ALSO sh(1), execve(2), fork(2), waitpid(2), popen(3)
STANDARDS The system() function conforms to ISO/IEC 9899:1990 (``ISO C90'') and is expected to be IEEE Std 1003.2 (``POSIX.2'') compatible.
BSD June 4, 1993 BSD
Given this, your error of 32256 is being generated by the shell -- meaning the command you ran exited with that status.
It might be more helpful if you can give a concise example of the specific code that is failing.
John Francini
On 14 Jun 2006, at 14:12, Matthew Jaffa wrote:
Yes I read the man page, and it says -1 if not successful, 0 if successful, and returns non-zero if the command you pass in is NULL, but I know I didn't pass in null cause I log it right before I execute the command.
Matt
From: "Justin C. Walker" < justin@mac.com> To: "darwin-dev@lists.apple.com list" <darwin-dev@lists.apple.com > Subject: Re: system command returning unknown error. Date: Wed, 14 Jun 2006 10:38:46 -0700
On Jun 14, 2006, at 10:30 , matt jaffa wrote:
Hi,
I am calling system(char* command) in my .cpp file. But this is returning error 32256. This error no. is not documented so I don't know why it is not working. Anyone seen this error number before and know what it means.
Did you read the man page for the 'system()' call?
Regards,
Justin
-- Justin C. Walker, Curmudgeon at Large Director Institute for the Enhancement of the Director's Income ----------- Nobody knows the trouble I've been -----------
_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list ( Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-dev/mtjaffa% 40msn.com
This email sent to mtjaffa@msn.com
_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list ( Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-dev/francini% 40mac.com
This email sent to francini@mac.com
_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list ( Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-dev/mjaffa%40gmail.com
This email sent to mjaffa@gmail.com
_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... On 6/14/06, matt jaffa <mjaffa@gmail.com> wrote: This email sent to site_archiver@lists.apple.com
participants (1)
-
matt jaffa