[erlang-questions] where is os:getuid() ?

zxq9 zxq9@REDACTED
Tue Nov 24 05:39:28 CET 2015

On Tuesday 24 November 2015 16:41:42 Richard A. O'Keefe wrote:
> Erlang doesn't just run under Unix-family operating
> systems.  If you're running under Cygwin,
> https://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-common
> says how Windows identifiction <-> uid/gid work.
> I can't get a response from www.erlang.org at the moment,
> so I can't check this, but I thought Erlang could run
> directly under Windows without Cygwin.  In that case,
> what should os:gete?[ug]id() do?
> Considering the hoops that Windows->uid/gid mapping has
> to (or may) jump through under Cygwin, it's not clear
> that their signal-safety under OpenBSD tells us much about
> Windows...

Indeed it does run under Windows, and does not require Cygwin.
I read through the Windows build process a while back, and though
a bit convoluted, iirc it is built with Visual Studio (and there
were notes in there indicating that clean builds on mingw and
VS was a goal).

So... what should os:getuid/0 do?

Does anyone see a downside to returning whatever is a native
id relative to a given system in a tuple that indicates the nature
of the system? In particular, whatever is consistent with os:type/0:

-spec os:getuid() -> {System, Id}
  when System :: {unix, linux} | {unix, bsd} | {win, nt} % etc...
       Id     :: unix_id() | win_id()                    % etc...

Defining unix_id() may be too broad, and I have no idea how win_id()
should be represented. The basic idea is letting different systems
do their own things but tagging them in a way consistent with os:type/0.
This could be a big win -- as long as the various types were well

Breaking too far out of a runtime cross-platform can get ugly pretty
quickly, but I can imagine some uses for this.


More information about the erlang-questions mailing list