Skip to content

Commit 29e0c5c

Browse files
authored
🐛 Don't test "Resource busy" when detaching (#200)
1. We have EBUSY (code 16) https://ss64.com/osx/hdiutil.html said: > [EBUSY] Resource busy. Used if necessary exclusive access cannot be obtained. This error often appears when a volume can't be unmounted. "EBUSY" can be found in /sys/errno.h of the BSD kernel: https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/errno.h#L108 : > #define EBUSY 16 /* Device / Resource busy */ https://github.com/freebsd/freebsd-src/blob/1e0a518d65488caafff89a4ecba9cfb2be233379/sys/sys/errno.h#L69 : > #define EBUSY 16 /* Device busy */ 2. Error messages will be localized For example: | Language | "Resource busy" | -------- | --------------- | Chinese | 资源忙 | Chinese | 資源忙碌中 | Japanese | リソースが使用中です | Russian | Ресурс занят 3. Conculsion We should not test the content of the error message. Just testing the exit code "16" is sufficient and reliable.
1 parent dd7b7f7 commit 29e0c5c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/hdiutil.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ exports.detach = function (path, cb) {
6666
let attempts = 0
6767
function attemptDetach (err) {
6868
attempts += 1
69-
if (err && (err.exitCode === 16 || err.code === 16) && /Resource busy/.test(err.stderr) && attempts <= 5) {
69+
if (err && (err.exitCode === 16 || err.code === 16) && attempts <= 5) {
7070
setTimeout(function () {
7171
util.sh('hdiutil', args, attemptDetach)
7272
}, 1000 * Math.pow(2, attempts - 1))

0 commit comments

Comments
 (0)