Re: 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=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=DzoirhZ7q2HS8tEITxfV7G3c2Bb8XfagRQkhUN2l80Q=; b=ZL3iiGUnoGC+rcuuReGJcnWznQC40o6Oi3wXGAFyJ4QTkPD9bCao03F+GRz1FM6OSD ypqDonmyWx1rfVl9CLxh8tdClYuwi7qjV58xU7yQn9BpICMa9DsCnkEPstwms+vo1gsL 4xlNAG78WVXgvCKfyGQPlx7dK2bmGxpTQwSmzdNz88NJFARTkrcfepkazJcj0oDz1ENY ECku0NPF9NvzA1lo/QhhZODhBoeN2MYe1f8kC57U/RvgXlqZwrbA7bKSqyEEsx5EVub0 ua4feKxR2wwYiF+6zEMyD0qnr02uQMv63ZQVjiK2YpSAKOblJGfmezpeEeLh6n9cVcIU xbAw== Even on Linux, if the executable is execute-only (no write access), you wouldn't be able to read it via /proc/self/exe (I tried). So even there, there's no guaranteed solution.
On Jul 2, 2018, at 19:34, Alec Mocatta <alec@mocatta.net> wrote:
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/rlhamil2%40gmail.com
This email sent to rlhamil2@gmail.com
_______________________________________________ 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)
-
Richard L. Hamilton