• 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: Best way to launch command-line program from C++ application
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best way to launch command-line program from C++ application


  • Subject: Re: Best way to launch command-line program from C++ application
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Fri, 20 Mar 2009 22:06:44 +0100

Le 20 mars 09 à 21:48, David Gagnon a écrit :

Hi,

Our program is a C++ plug-in for Acrobat. So, we need to launch a
command-line program to send HTTP message (sending HTTP message within a
plug-in cause many problems). Our small command line program take 1
parameter (path) and return an error value. So, I tried "exec" but it does
not work, because Acrobat is multi-process. See this link:

http://factor-language.blogspot.com/2007/07/execve-returning-enotsup-on-mac-
os-x.html


You should only call exec after a fork call, so that is not an issue and the fact that Acrobat is multithreaded should not have any impact.

The solution is in the link you provided.

pid_t p = fork();
if(p < 0)
{
  scream_bloody_murder();
  return;
}

if(p == 0) {
  execve(whatever);
}

Also, posix_spawn could be a nice choice but it is available in 10.5 only.
So I think that "system" or "popen" are the most credible candidate now.

Have a better/simpler idea?

using Obj-C++ and NSTask to launch the tool.

As this is Foundation only, you don't even have to bother with NSApplicationLoad() and other Cocoa/Carbon integration tricks (except NSAutoReleasePool).

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Best way to launch command-line program from C++ application (From: David Gagnon <email@hidden>)

  • Prev by Date: Re: Best way to launch command-line program from C++ application
  • Next by Date: Re: Best way to launch command-line program from C++ application
  • Previous by thread: Re: Best way to launch command-line program from C++ application
  • Next by thread: Re: Best way to launch command-line program from C++ application
  • Index(es):
    • Date
    • Thread