72052
|
1 |
(* Title: Pure/ML/ml_pid.ML
|
|
2 |
Author: Makarius
|
|
3 |
|
|
4 |
Native PID for ML process.
|
|
5 |
*)
|
|
6 |
|
|
7 |
signature ML_PID =
|
|
8 |
sig
|
|
9 |
val get: unit -> int
|
|
10 |
end;
|
|
11 |
|
72114
|
12 |
structure ML_Pid: ML_PID =
|
72052
|
13 |
struct
|
|
14 |
|
73587
|
15 |
\<^if_windows>\<open>
|
|
16 |
val get =
|
|
17 |
Foreign.buildCall0
|
|
18 |
(Foreign.getSymbol (Foreign.loadLibrary "kernel32.dll") "GetCurrentProcessId", (), Foreign.cInt);
|
|
19 |
\<close>
|
|
20 |
|
|
21 |
\<^if_unix>\<open>
|
|
22 |
val get = Posix.ProcEnv.getpid #> Posix.Process.pidToWord #> SysWord.toLargeInt;
|
|
23 |
\<close>
|
72052
|
24 |
|
|
25 |
end;
|