• 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: Determining how the app is run (intel/ppc/rosetta/os version)?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Determining how the app is run (intel/ppc/rosetta/os version)?


  • Subject: Re: Determining how the app is run (intel/ppc/rosetta/os version)?
  • From: Greg Hurrell <email@hidden>
  • Date: Sun, 21 May 2006 15:43:34 +0200

El 21/05/2006, a las 15:09, Gerben Wierda escribió:

Anyway, I am curious if and how you handle (amongst others):

Well, I suspect we are trying to solve slightly different problems, but anyway...


- getting the pid of your subprocess where the subprocesses are many, some slightly equivalent (e.g. checking GPG signatures with gpg or MD5 hashes on files with openssl).

I don't have *multiple* simultaneous subprocesses but I do run subprocesses (one at a time) from a separate worker thread so as to keep the user interface responsive. I also return the output in one hit at the end of execution rather than incrementally, but if I did need to return output a line at a time I'd use performSelectorOnMainThread:withObject:waitUntilDone:


- finding out if your subprocess is still running

I don't use an NSTask subclass to do this, so it's not something I've ever had to worry about. But elsewhere in the code where I need to observe the lifetime of another process without polling I use the mach port dead name notifications described here:


http://developer.apple.com/technotes/tn/tn2050.html

- getting stderr and stdout separately from your subprocess as it runs and appending it to a view

In my case I log to the console directly, not to a view: but if I did want to do that I'd use the performSelectorOnMainThread:withObject:waitUntilDone: method I mentioned above.


As for getting them separately, I don't know how you'd do that in the case of AuthorizationExecuteWithPrivileges() because it only provides a single parameter for setting up a communications pipe, which is connected to "to the tool’s standard input and output".

- influencing the environment of your subprocess

I'm not sure if getenv(), putenv(), setenv() have influence over a subprocess that's been launched with root privileges AuthorizationExecuteWithPrivileges(). I imagine they get propagated by fork(), which is probably what ultimately underlies AuthorizationExecuteWithPrivileges(), but I don't know if AuthorizationExecuteWithPrivileges() "cleans" the environment before launching.


If it does do such cleaning then I suppose the only way to influence the environment is to make your own suid helper tool which handles the setting up of the environment before executing the real subprocess that you want to run.

In other words, the many of the things that NSTask can do.

Well, like I said, not really trying to solve the same problems as you, but I agree it would be neat to wrap all this stuff up in an NSTask subclass.


Cheers,
Greg


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

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

This email sent to email@hidden

  • Follow-Ups:
    • Re: Determining how the app is run (intel/ppc/rosetta/os version)?
      • From: Gerben Wierda <email@hidden>
References: 
 >Re: Determining how the app is run (intel/ppc/rosetta/os version)? (From: Gerben Wierda <email@hidden>)
 >Re: Determining how the app is run (intel/ppc/rosetta/os version)? (From: Greg Hurrell <email@hidden>)
 >Re: Determining how the app is run (intel/ppc/rosetta/os version)? (From: Gerben Wierda <email@hidden>)

  • Prev by Date: Stop NSTableColumn from being dragged, and from changing position (like iTunes)
  • Next by Date: Re: Cocoa-dev Digest, Vol 3, Issue 675
  • Previous by thread: Re: Determining how the app is run (intel/ppc/rosetta/os version)?
  • Next by thread: Re: Determining how the app is run (intel/ppc/rosetta/os version)?
  • Index(es):
    • Date
    • Thread