src/Pure/ML/ml_pid.ML
author wenzelm
Mon, 20 May 2024 15:43:51 +0200
changeset 80182 29f2b8ff84f3
parent 73587 d1767bcb79ec
permissions -rw-r--r--
proper support for "isabelle update -D DIR": avoid accidental exclusion of select_dirs (amending e5dafe9e120f);

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

Native PID for ML process.
*)

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

structure ML_Pid: ML_PID =
struct

\<^if_windows>\<open>
  val get =
    Foreign.buildCall0
      (Foreign.getSymbol (Foreign.loadLibrary "kernel32.dll") "GetCurrentProcessId", (), Foreign.cInt);
\<close>

\<^if_unix>\<open>
  val get = Posix.ProcEnv.getpid #> Posix.Process.pidToWord #> SysWord.toLargeInt;
\<close>

end;