Read current executable even if it's been deleted?
site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mocatta.net; s=google; h=mime-version:from:date:message-id:subject:to; bh=IzVlJc1HvmjvAKdcBcXRBdQ0wSuqjycDigz9WgufFno=; b=S7rHY+A2keZB0YddUDmQ8e73xarllqtbVB/JEhhPmwuthf4G5RGwkRmQQv96wqjAO5 wNJA0xz53y0yQb5/Wtds5m8vx6ax31N+beG3KUjwaIUpXzRUJNHrVwztV5CgCd8E9nZ6 7nAAox7sXQXuB5hwHfGM1SeIoNgI2yVMyAs2I= Linux has a path in the /proc filesystem – /proc/self/exe – which lets one read the contents of ones own executable, even if it has since been deleted or was exec'd in an atypical manner (e.g. execve("/proc/self/fd/123", ...)). On Darwin/macOS I can use _NSGetExecutablePath() to get the path to the current executable. The problem is this breaks in the aforementioned cases: namely deletion/moving. Is there a way to read the contents of ones own executable, that works in the face of deletion/moving? Thanks, Alec _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.... This email sent to site_archiver@lists.apple.com
participants (1)
-
Alec Mocatta