Re: Read current executable even if it's been deleted?
Re: Read current executable even if it's been deleted?
- Subject: Re: Read current executable even if it's been deleted?
- From: "Richard L. Hamilton" <email@hidden>
- Date: Mon, 02 Jul 2018 20:17:36 -0400
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 <email@hidden> 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 (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden