src/Pure/ML/ml_pid.ML
author wenzelm
Fri, 07 Aug 2020 21:02:02 +0200
changeset 72114 d00220799735
parent 72052 912f13865596
child 73587 d1767bcb79ec
permissions -rw-r--r--
tuned names;

(*  Title:      Pure/ML/ml_pid.ML
    Author:     Makarius

Native PID for ML process.
*)

signature ML_PID =
sig
  val get: unit -> int
end;

if ML_System.platform_is_windows then ML
\<open>
structure ML_Pid: ML_PID =
struct

val get =
  Foreign.buildCall0
    (Foreign.getSymbol (Foreign.loadLibrary "kernel32.dll") "GetCurrentProcessId", (), Foreign.cInt);

end;
\<close>
else ML
\<open>
structure ML_Pid: ML_PID =
struct

val get = Posix.ProcEnv.getpid #> Posix.Process.pidToWord #> SysWord.toLargeInt

end;
\<close>