[Adium-devl] Let's abandon disk images
Graham Booker
adium at cod3r.com
Sat Mar 31 21:04:49 UTC 2007
On Mar 31, 2007, at 2:55 PM, Ofri Wolfus wrote:
> How about exec()ing to umount or something like that? ;-)
>
> - Ofri
>
For some reason, OS X applications do not like you to do an exec. If
you already started running NSApplication, the exec tends to just
fail. You have to do a fork/exec instead. Annoying, but true. I
found this out when doing an update checker for perian which has to
worry about the existing app (really bundle) in use. Anyway, this is
what I suggest:
Sparkle has some code which does the relaunch in the following manner:
system("/bin/bash -c '{ for (( i = 0; i < 3000 && $(echo $(/bin/ps -
xp $PPID|/usr/bin/wc -l))-1; i++ )); do\n"
" /bin/sleep .2;\n"
" done\n"
" if [[ $(/bin/ps -xp $PPID|/usr/bin/wc -l) -ne 2 ]];
then\n"
" /usr/bin/open \"${LAUNCH_PATH}\"\n"
" fi\n"
" rm -rf \"${TEMP_FOLDER}\"\n"
"} &>/dev/null &'");
We could just change the system to be a fork/exec combo, and change
the rm -rf to be an hdiutil detach or something like that to detach
the image. Here is a link to the fork/exec stuff we did in perian:
http://trac.perian.org/browser/trunk/Update%20Checker%20Sources/
UpdateCheckerAppDelegate.m#L201
The advantage of the above script is that it waits for the existing
app to quit before it does the relaunch, and so in theory, the disk
image should no longer be in use. Although, I have issues with using
system to launch an bash process which waits for the parent pid to
exit. System launches sh with the argument passed into it, and
blocks until the sh finishes. The sh then launches the bash process
with the script in it in the background. The bash process waits in a
loop for its parent to finish, which is the sh process, not the
application itself. It seems to be sheer luck that the above works.
I would prefer it to wait on a particular pid, which the application
gives it, but that is just me.
> - - - - - - - - - - - - - - - - - - -
> http://www.dpompa.com
> - - - - - - - - - - - - - - - - - - -
>
>
> On 31/03/2007, at 22:45, Evan Schoenberg wrote:
>
>> Might have problems doing that from within the launched
>> application, since it's running from the disk... but that would be
>> a nice bonus if feasible.
>
> _______________________________________________
> Adium-devl mailing list
> Adium-devl at adiumx.com
> http://adiumx.com/mailman/listinfo/adium-devl_adiumx.com
- Graham
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://adium.im/pipermail/devel_adium.im/attachments/20070331/29c36258/attachment-0001.html>
More information about the devel
mailing list