• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: execv bug???
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: execv bug???


  • Subject: Re: execv bug???
  • From: Steve Checkoway <email@hidden>
  • Date: Sun, 27 Jan 2008 04:38:23 -0800


On Jan 27, 2008, at 12:12 AM, Peter Seebach wrote:

In message <email@hidden>, 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. If you call fork(2) and a subsequent exec* fails, then you must call _exit(2). 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.




So, the chdir on all other platforms goes to /var/qmail, and, the execv
executes from there bin/qmail-queue.

So the program you want to execute is /var/qmail/bin/qmail-queue? Seems like a strange place for it.


No, because as a simple test program shows, that works:

	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 *. 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." That said, execv(3) works for me without an absolute path as well.


--
Steve Checkoway

    "Anyone who says that the solution is to educate the users
    hasn't ever met an actual user." -- Bruce Schneier




Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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

  • Follow-Ups:
    • Re: execv bug???
      • From: email@hidden (Peter Seebach)
References: 
 >Re: execv bug??? (From: email@hidden (Peter Seebach))

  • Prev by Date: Re: execv bug???
  • Next by Date: Re: execv bug???
  • Previous by thread: Re: execv bug???
  • Next by thread: Re: execv bug???
  • Index(es):
    • Date
    • Thread