| 50 | } |
| 51 | |
| 52 | function isLinuxMusl() { |
| 53 | if (process.platform !== 'linux') { |
| 54 | return false; |
| 55 | } |
| 56 | |
| 57 | // Look at which libc loader is mapped into this process (See #1517, #1527). |
| 58 | try { |
| 59 | const maps = fs.readFileSync('/proc/self/maps', 'latin1'); |
| 60 | if (/\/ld-musl-[^/\s]*\.so/.test(maps)) return true; |
| 61 | if (/\/(?:ld-linux[^/\s]*|libc)\.so\.\d/.test(maps)) return false; |
| 62 | } catch {} |
| 63 | |
| 64 | // Fallback detection (less reliable, potentially slow). |
| 65 | const { report } = process; |
| 66 | const previousExcludeNetwork = report.excludeNetwork; |
| 67 | report.excludeNetwork = true; |
| 68 | try { |
| 69 | return !report.getReport().header.glibcVersionRuntime; |
| 70 | } finally { |
| 71 | report.excludeNetwork = previousExcludeNetwork; |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | exports.getBinding = getBinding; |
| 76 | exports.getPrebuildPath = getPrebuildPath; |