site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com In message <ECF90C22-4D4E-46C0-AD7D-93A2F4A1681F@pahtak.org>, Steve Checkoway w rites:
On Jan 27, 2008, at 12:12 AM, Peter Seebach wrote:
In message <479C20CF.1080900@yahoo.com>, Steve writes:
if (chdir(auto_qmail) == -1) _exit(61); execv(*binqqargs,binqqargs); _exit(120);
Calling _exit from user code is nearly always a mistake.
This is not true at all.
In general it is, but..
If you call fork(2) and a subsequent exec* fails, then you must call _exit(2).
Well, not necessarily. You may need to, if...
exit(3) calls functions registered with atexit, flushes open output streams, closes open streams, and unlinks files created with tmpfile(3).Calling exit(3) will cause the open output streams to flush twice.
I somehow doubt that djb's code uses tmpfile(). It is possible that it leaves output streams unflushed, but I'd be surprised. But yes -- this is presumably the path leading to an exec, so failures should avoid doing all that cleanup. If there is any, which I would rather doubt.
So the program you want to execute is /var/qmail/bin/qmail-queue? Seems like a strange place for it.
It is a strange place, but that's how qmail works -- it puts everything in /var/qmail.
static char *ev[] = { 0, 0 };
int main(void) { ev[0] = "bin/ls"; chdir("/"); execv(*ev, ev); return 23; }
You're assigning a const char * to a char *.
No I'm not.
I'm not sure why gcc doesn't warn about this, but I suspect that it should. In fact, if you assign "bin/ls" to a const char * first, then it does warn, "warning: assignment discards qualifiers from pointer target type."
Well, yes. Because then there'd be a const char * involved. String literals are not const-qualified, even though their contents may not be modified. -s _______________________________________________ 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... This email sent to site_archiver@lists.apple.com
participants (1)
-
seebs@seebs.net