Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when detaching volume using hdiutil on OS X

Ive got a program that runs on Mac OS 10.5.8. The program runs a continuous cycle where it mounts an image, installs a browser plugin and unmounts the image again. If I leave this program running I eventually end up in a situation where I get the following error "fork: resource temporarily unavailable". In the activity monitor I can see that several hundreds of processes called diskimages-helper are running. Does anyone know why this happens and how I can avoid it? Below are the commands I use during one cycle of the program.

# First I remove the plugin
rm -rf "/Library/Internet Plug-Ins/my.plugin"

# If the mount exists I unmount it
hdiutil unmount [mount] -force

# If that doesnt work I detach the device
hdiutil detach [device] -force

# Then I mount the image
hdiutil mount [image]

# I install the plugin
installer -package [package] -target /

# Unmount
hdiutil unmount [mount] -force

# And if necessary detach
hdiutil detach [device] -force
like image 337
Bas Smit Avatar asked Oct 28 '10 18:10

Bas Smit


1 Answers

You need to always detach the disk image -- unmounting it unmounts the filesystem, but leaves disk image attached to a /dev/disk* entry, with a diskimages-helper process running to handle it. Note that hdiutil detach will take care of unmounting the volume for you (provided Disk Arbitration is running), so you can just skip the unmount step.

like image 127
Gordon Davisson Avatar answered Nov 03 '22 07:11

Gordon Davisson